[PATCH v8 0/2] perf tests: Add uncore and x86 topdown event sorting tests
From: Ian Rogers
Date: Mon May 18 2026 - 02:37:37 EST
A patch thread changing event sorting highlighted a lack of testing
for the more complicated uncore and x86 perf metric event sorting:
https://lore.kernel.org/linux-perf-users/CAP-5=fWRgDo7UnJAD4C--d=mVPRhOEWZVyU7nVM1YEp3jncAgg@xxxxxxxxxxxxxx/
v8: Simplify event_cb in the uncore event sorting test by removing the
unreachable dead-code else block (reported by Sashiko).
v7: - Prevent double-free of m.event1 and dangling pointer access upon
PMU scanning loop termination or early continue in the uncore
event sorting test by utilizing standard perf zfree() helpers
(reported by Sashiko).
- Document Intel Hybrid CPU architectural invariants in the x86
topdown test to clarify why instructions correctly leads a group
of 2 on E-cores (cpu_atom) where slots is unsupported and
filtered out (reported by Sashiko).
v6: - Ensure robust error initialization and resource cleanup in both
uncore and topdown tests by initializing evlist to NULL and
parse_events_error at function entry, preventing uninitialized
stack access or resource leaks on early return paths (reported
by Sashiko).
- Prevent double evaluation and duplicate debug logging upon test
assertion failure in the x86 topdown test by caching test_sort()
return values into local variables (reported by Sashiko).
v5: - Strengthen uncore event sorting test assertions to require at
least 4 total events (>= 2 groups of 2 events) instead of > 0
events, guaranteeing that multi-PMU wildcard expansion is
genuinely exercised across multiple sibling PMUs (reported by Sashiko).
- Fix memory leaks on assertion failure across both uncore and
topdown test suites by replacing standard TEST_ASSERT macros
with local CHECK macros that correctly branch to out_err cleanup
handlers (reported by Sashiko).
- Fix test_sort() in the x86 topdown test to correctly return TEST_FAIL (-1)
instead of parse_events() internal error codes (e.g., -EINVAL) when event
parsing fails (reported by Namhyung).
v4: Fix malformed event group string formatting in the uncore event
sorting test when running on AMD systems (where sysfs event
aliases lack JSON descriptions - reported by Namhyung). Added a
helper to strip redundant PMU prefixes and trailing slashes to
ensure parse_events() receives valid syntax across all
architectures.
v3: Address sashiko nits on using evsel__name and ensuring slots is injected.
https://lore.kernel.org/linux-perf-users/20260331185419.4085479-1-irogers@xxxxxxxxxx/
v2: Address indentation and other nits from Namhyung. Add Zide Chen's
tested-by tags.
https://lore.kernel.org/lkml/20260331165207.4016392-1-irogers@xxxxxxxxxx/
v1: https://lore.kernel.org/lkml/20260325183045.1229502-1-irogers@xxxxxxxxxx/
Ian Rogers (2):
perf tests: Add test for uncore event sorting
perf arch x86 tests: Add test for topdown event sorting
tools/perf/arch/x86/tests/topdown.c | 166 +++++++++++++++++++++-
tools/perf/tests/Build | 1 +
tools/perf/tests/builtin-test.c | 1 +
tools/perf/tests/tests.h | 1 +
tools/perf/tests/uncore-event-sorting.c | 176 ++++++++++++++++++++++++
5 files changed, 344 insertions(+), 1 deletion(-)
create mode 100644 tools/perf/tests/uncore-event-sorting.c
--
2.54.0.563.g4f69b47b94-goog