diff options
author | Ray Kinsella <mdr@ashroe.eu> | 2021-09-30 15:15:32 +0100 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2021-10-05 10:44:39 +0000 |
commit | ede7143386ce1cf086066eec06dbdf7cf6d4cfee (patch) | |
tree | 9e6aad9d33551c9abf8813b52f449d0919f849d0 /src/plugins/perfmon/perfmon.h | |
parent | 4189108e1dbac0a7961d31d59a21b7fe8354ce61 (diff) |
perfmon: bundles with multiple types
Allow perfmon bundles to support more than one bundle type, either node
or thread. Only used for topdown bundle for the moment.
Type: improvement
Signed-off-by: Ray Kinsella <mdr@ashroe.eu>
Change-Id: Iba3653a4deb39b0a8ee8ad448a7e8f954283ccd8
Diffstat (limited to 'src/plugins/perfmon/perfmon.h')
-rw-r--r-- | src/plugins/perfmon/perfmon.h | 61 |
1 files changed, 50 insertions, 11 deletions
diff --git a/src/plugins/perfmon/perfmon.h b/src/plugins/perfmon/perfmon.h index ffcf2fd5e46..f9b9070d077 100644 --- a/src/plugins/perfmon/perfmon.h +++ b/src/plugins/perfmon/perfmon.h @@ -32,8 +32,23 @@ typedef enum PERFMON_BUNDLE_TYPE_THREAD, PERFMON_BUNDLE_TYPE_SYSTEM, PERFMON_BUNDLE_TYPE_MAX, + PERFMON_BUNDLE_TYPE_NODE_OR_THREAD, } perfmon_bundle_type_t; +#define foreach_perfmon_bundle_type \ + _ (PERFMON_BUNDLE_TYPE_UNKNOWN, "not supported") \ + _ (PERFMON_BUNDLE_TYPE_NODE, "node") \ + _ (PERFMON_BUNDLE_TYPE_THREAD, "thread") \ + _ (PERFMON_BUNDLE_TYPE_SYSTEM, "system") + +typedef enum +{ +#define _(e, str) e##_FLAG = 1 << e, + foreach_perfmon_bundle_type +#undef _ + +} perfmon_bundle_type_flag_t; + typedef enum { PERFMON_OFFSET_TYPE_MMAP, @@ -108,7 +123,14 @@ typedef struct perfmon_bundle char *description; char *source; char *footer; - perfmon_bundle_type_t type; + + union + { + perfmon_bundle_type_flag_t type_flags; + perfmon_bundle_type_t type; + }; + perfmon_bundle_type_t active_type; + perfmon_offset_type_t offset_type; u32 events[PERF_MAX_EVENTS]; u32 n_events; @@ -179,23 +201,40 @@ typedef struct extern perfmon_main_t perfmon_main; +#define PERFMON_BUNDLE_TYPE_TO_FLAGS(type) \ + ({ \ + uword rtype = 0; \ + if (type == PERFMON_BUNDLE_TYPE_NODE_OR_THREAD) \ + rtype = \ + 1 << PERFMON_BUNDLE_TYPE_THREAD | 1 << PERFMON_BUNDLE_TYPE_NODE; \ + else \ + rtype = 1 << type; \ + rtype; \ + }) + always_inline uword -perfmon_cpu_supported_bundle_type (perfmon_bundle_t *b) +perfmon_cpu_update_bundle_type (perfmon_bundle_t *b) { perfmon_cpu_supports_t *supports = b->cpu_supports; uword type = 0; - /* if nothing specific for this bundle, go with the default */ - if (!supports) - return b->type; + /* either supports or b->type should be set, but not both */ + ASSERT (!!supports ^ !!b->type); - /* the last specified type, will always win */ - for (int i = 0; i < b->n_cpu_supports; ++i) - if (supports[i].cpu_supports ()) - type = supports[i].bundle_type; + /* if nothing specific for this bundle, go with the defaults */ + if (!supports) + type = PERFMON_BUNDLE_TYPE_TO_FLAGS (b->type); + else + { + /* more than one type may be supported by a given bundle */ + for (int i = 0; i < b->n_cpu_supports; ++i) + if (supports[i].cpu_supports ()) + type |= PERFMON_BUNDLE_TYPE_TO_FLAGS (supports[i].bundle_type); + } return type; } +#undef PERFMON_BUNDLE_TYPE_TO_FLAGS #define PERFMON_REGISTER_SOURCE(x) \ perfmon_source_t __perfmon_source_##x; \ @@ -213,8 +252,8 @@ perfmon_cpu_supported_bundle_type (perfmon_bundle_t *b) { \ perfmon_main_t *pm = &perfmon_main; \ __perfmon_bundle_##x.next = pm->bundles; \ - __perfmon_bundle_##x.type = \ - perfmon_cpu_supported_bundle_type (&__perfmon_bundle_##x); \ + __perfmon_bundle_##x.type_flags = \ + perfmon_cpu_update_bundle_type (&__perfmon_bundle_##x); \ pm->bundles = &__perfmon_bundle_##x; \ } \ perfmon_bundle_t __perfmon_bundle_##x |