diff options
Diffstat (limited to 'tools/perf/arch/x86/util/topdown.c')
-rw-r--r-- | tools/perf/arch/x86/util/topdown.c | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/tools/perf/arch/x86/util/topdown.c b/tools/perf/arch/x86/util/topdown.c index 3f9a267d4501..49f25d67ed77 100644 --- a/tools/perf/arch/x86/util/topdown.c +++ b/tools/perf/arch/x86/util/topdown.c @@ -32,6 +32,52 @@ bool topdown_sys_has_perf_metrics(void) } #define TOPDOWN_SLOTS 0x0400 +bool arch_is_topdown_slots(const struct evsel *evsel) +{ + if (evsel->core.attr.config == TOPDOWN_SLOTS) + return true; + + return false; +} + +static int compare_topdown_event(void *vstate, struct pmu_event_info *info) +{ + int *config = vstate; + int event = 0; + int umask = 0; + char *str; + + if (!strcasestr(info->name, "topdown")) + return 0; + + str = strcasestr(info->str, "event="); + if (str) + sscanf(str, "event=%x", &event); + + str = strcasestr(info->str, "umask="); + if (str) + sscanf(str, "umask=%x", &umask); + + if (event == 0 && *config == (event | umask << 8)) + return 1; + + return 0; +} + +bool arch_is_topdown_metrics(const struct evsel *evsel) +{ + struct perf_pmu *pmu = evsel__find_pmu(evsel); + int config = evsel->core.attr.config; + + if (!pmu || !pmu->is_core) + return false; + + if (perf_pmu__for_each_event(pmu, false, &config, + compare_topdown_event)) + return true; + + return false; +} /* * Check whether a topdown group supports sample-read. @@ -44,7 +90,7 @@ bool arch_topdown_sample_read(struct evsel *leader) if (!evsel__sys_has_perf_metrics(leader)) return false; - if (leader->core.attr.config == TOPDOWN_SLOTS) + if (arch_is_topdown_slots(leader)) return true; return false; |