perf topdown: Use attribute to see an event is a topdown metic or slots
authorIan Rogers <irogers@google.com>
Sat, 19 Jul 2025 03:05:15 +0000 (20:05 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 24 Jul 2025 20:41:35 +0000 (13:41 -0700)
commit5b546de9cc177936a3ed07d7d46ef072db4fdbab
tree6702a5f5f1bee3c7a8175ca1e49c3d24938ccce6
parent811082e4b668db9689f8ce927a106036b4ed4e96
perf topdown: Use attribute to see an event is a topdown metic or slots

The string comparisons were overly broad and could fire for the
incorrect PMU and events. Switch to using the config in the attribute
then add a perf test to confirm the attribute config values match
those of parsed events of that name and don't match others. This
exposed matches for slots events that shouldn't have matched as the
slots fixed counter event, such as topdown.slots_p.

Fixes: fbc798316bef ("perf x86/topdown: Refine helper arch_is_topdown_metrics()")
Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250719030517.1990983-14-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/arch/x86/include/arch-tests.h
tools/perf/arch/x86/tests/Build
tools/perf/arch/x86/tests/arch-tests.c
tools/perf/arch/x86/tests/topdown.c [new file with mode: 0644]
tools/perf/arch/x86/util/evsel.c
tools/perf/arch/x86/util/topdown.c
tools/perf/arch/x86/util/topdown.h