[PATCH 1/3] perf list: Order events by event name before PMU name
From: James Clark
Date: Tue Mar 04 2025 - 08:50:29 EST
In order to be able to show a single line for the same events on
different PMUs, they need to be grouped by event name. This is because
deduplication relies on similar items being adjacent in the list.
Even without the following changes this would arguably be better
grouping because it's easier to find events in a topic alphabetically
by name, rather than in separate PMU blocks.
Signed-off-by: James Clark <james.clark@xxxxxxxxxx>
---
tools/perf/util/pmus.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tools/perf/util/pmus.c b/tools/perf/util/pmus.c
index dd7c2ffdab38..4d60bac2d2b9 100644
--- a/tools/perf/util/pmus.c
+++ b/tools/perf/util/pmus.c
@@ -445,15 +445,15 @@ static int cmp_sevent(const void *a, const void *b)
if (a_iscpu != b_iscpu)
return a_iscpu ? -1 : 1;
- /* Order by PMU name. */
- if (as->pmu != bs->pmu) {
- ret = strcmp(as->pmu_name ?: "", bs->pmu_name ?: "");
- if (ret)
- return ret;
- }
-
/* Order by event name. */
- return strcmp(as->name, bs->name);
+ ret = strcmp(as->name, bs->name);
+ if (ret)
+ return ret;
+
+ /* Order by PMU name. */
+ if (as->pmu == bs->pmu)
+ return 0;
+ return strcmp(as->pmu_name ?: "", bs->pmu_name ?: "");
}
static bool pmu_alias_is_duplicate(struct sevent *a, struct sevent *b)
--
2.34.1