Skip to content

Commit c60b7d6

Browse files
namhyungacmel
authored andcommitted
perf pmu: Use available core PMU for raw events
When it finds a matching PMU for a legacy event, it should look for core PMUs. The raw events also refers to core events so it should be handled similarly. On x86, PERF_TYPE_RAW should match with the existing cpu PMU. But on ARM, there's no PMU with the matching type so it'll pick the first core PMU for it. Suggested-by: Ian Rogers <[email protected]> Reviewed-by: Ian Rogers <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent c42e219 commit c60b7d6

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

tools/perf/util/pmus.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,14 +727,21 @@ struct perf_pmu *evsel__find_pmu(const struct evsel *evsel)
727727
legacy_core_type =
728728
evsel->core.attr.type == PERF_TYPE_HARDWARE ||
729729
evsel->core.attr.type == PERF_TYPE_HW_CACHE;
730-
if (!pmu && legacy_core_type) {
731-
if (perf_pmus__supports_extended_type()) {
732-
u32 type = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT;
730+
if (!pmu && legacy_core_type && perf_pmus__supports_extended_type()) {
731+
u32 type = evsel->core.attr.config >> PERF_PMU_TYPE_SHIFT;
733732

734-
pmu = perf_pmus__find_by_type(type);
735-
} else {
736-
pmu = perf_pmus__find_core_pmu();
737-
}
733+
pmu = perf_pmus__find_by_type(type);
734+
}
735+
if (!pmu && (legacy_core_type || evsel->core.attr.type == PERF_TYPE_RAW)) {
736+
/*
737+
* For legacy events, if there was no extended type info then
738+
* assume the PMU is the first core PMU.
739+
*
740+
* On architectures like ARM there is no sysfs PMU with type
741+
* PERF_TYPE_RAW, assume the RAW events are going to be handled
742+
* by the first core PMU.
743+
*/
744+
pmu = perf_pmus__find_core_pmu();
738745
}
739746
((struct evsel *)evsel)->pmu = pmu;
740747
return pmu;

0 commit comments

Comments
 (0)