Skip to contentSkip to conversation

perf stat: Fix uniquify for hybrid systems

PATCH In review Thomas Falcon 2 participants 3 messages Feb 28, 2025 – Mar 3, 2025 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf stat: Fix uniquify for hybrid systems

Currently, perf stat is omitting the pmu name for legacy events on hybrid systems. git bisect indicated commit 357b965deba9 as the cause:

Bisecting: 0 revisions left to test after this (roughly 0 steps) [357b965deba9fb71467413e473764ec4e1694d8d] perf stat: Changes to event name uniquification

Include an additional check for hybrid architectures when determining whether to uniquify legacy events.

Before:

$ sudo ./perf stat -e cycles -a sleep 1

Performance counter stats for 'system wide':

       173,903,751      cycles
       666,423,950      cycles

       1.006615048 seconds time elapsed

After:

$ sudo ./perf stat -e cycles -a sleep 1

Performance counter stats for 'system wide':

       841,496,603      cpu_atom/cycles/
     3,308,929,412      cpu_core/cycles/

       1.002483283 seconds time elapsed
Fixes 357b965deba9 ("perf stat: Changes to event name uniquification")
---
 tools/perf/util/stat-display.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/stat-display.c +4 -2
index e65c7e9f15d1..df9f68080ec9 100644
@@ -1676,6 +1676,7 @@ static bool evlist__disable_uniquify(const struct evlist *evlist)
 
 static void evsel__set_needs_uniquify(struct evsel *counter, const struct perf_stat_config *config)
 {
+	bool hybrid = (!config->hybrid_merge && evsel__is_hybrid(counter));
 	struct evsel *evsel;
 
 	if (counter->merged_stat) {
@@ -1688,7 +1689,8 @@ static void evsel__set_needs_uniquify(struct evsel *counter, const struct perf_s
 		return;
 	}
 
-	if  (counter->core.attr.type < PERF_TYPE_MAX && counter->core.attr.type != PERF_TYPE_RAW) {
+	if (!hybrid && counter->core.attr.type < PERF_TYPE_MAX &&
+		counter->core.attr.type != PERF_TYPE_RAW) {
 		/* Legacy event, don't uniquify. */
 		return;
 	}
@@ -1705,7 +1707,7 @@ static void evsel__set_needs_uniquify(struct evsel *counter, const struct perf_s
 		return;
 	}
 
-	if (!config->hybrid_merge && evsel__is_hybrid(counter)) {
+	if (hybrid) {
 		/* Unique hybrid counters necessary. */
 		counter->needs_uniquify = true;
 		return;
Signature · 1 line
2.48.1
maintainer
#1 lore raw

Hello,

Quoted 27 lines · Thomas Falcon

Currently, perf stat is omitting the pmu name for legacy events on hybrid systems. git bisect indicated commit 357b965deba9 as the cause:

Bisecting: 0 revisions left to test after this (roughly 0 steps) [357b965deba9fb71467413e473764ec4e1694d8d] perf stat: Changes to event name uniquification

Include an additional check for hybrid architectures when determining whether to uniquify legacy events.

Before:

$ sudo ./perf stat -e cycles -a sleep 1

Performance counter stats for 'system wide':

       173,903,751      cycles
       666,423,950      cycles

       1.006615048 seconds time elapsed

After:

$ sudo ./perf stat -e cycles -a sleep 1

Performance counter stats for 'system wide':

Quoted 7 lines
       841,496,603      cpu_atom/cycles/
     3,308,929,412      cpu_core/cycles/

       1.002483283 seconds time elapsed
Fixes 357b965deba9 ("perf stat: Changes to event name uniquification")

Thanks for the fix, but there's a similar patch in the list. Please take a look.

https://lore.kernel.org/r/[email protected]

Thanks,
Namhyung

Quoted 38 lines
---
 tools/perf/util/stat-display.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/stat-display.c +4 -2
index e65c7e9f15d1..df9f68080ec9 100644
@@ -1676,6 +1676,7 @@ static bool evlist__disable_uniquify(const struct evlist *evlist)
 
 static void evsel__set_needs_uniquify(struct evsel *counter, const struct perf_stat_config *config)
 {
+	bool hybrid = (!config->hybrid_merge && evsel__is_hybrid(counter));
 	struct evsel *evsel;
 
 	if (counter->merged_stat) {
@@ -1688,7 +1689,8 @@ static void evsel__set_needs_uniquify(struct evsel *counter, const struct perf_s
 		return;
 	}
 
-	if  (counter->core.attr.type < PERF_TYPE_MAX && counter->core.attr.type != PERF_TYPE_RAW) {
+	if (!hybrid && counter->core.attr.type < PERF_TYPE_MAX &&
+		counter->core.attr.type != PERF_TYPE_RAW) {
 		/* Legacy event, don't uniquify. */
 		return;
 	}
@@ -1705,7 +1707,7 @@ static void evsel__set_needs_uniquify(struct evsel *counter, const struct perf_s
 		return;
 	}
 
-	if (!config->hybrid_merge && evsel__is_hybrid(counter)) {
+	if (hybrid) {
 		/* Unique hybrid counters necessary. */
 		counter->needs_uniquify = true;
 		return;
Signature · 1 line
2.48.1
#2 lore raw
Quoted 38 lines · Namhyung Kim

Hello,

Quoted 35 lines · Thomas Falcon

Currently, perf stat is omitting the pmu name for legacy events on hybrid systems. git bisect indicated commit 357b965deba9 as the cause:

Bisecting: 0 revisions left to test after this (roughly 0 steps) [357b965deba9fb71467413e473764ec4e1694d8d] perf stat: Changes to event
name uniquification

Include an additional check for hybrid architectures when determining
whether to uniquify legacy events.

Before:

$ sudo ./perf stat -e cycles -a sleep 1

 Performance counter stats for 'system wide':

       173,903,751      cycles
       666,423,950      cycles

       1.006615048 seconds time elapsed

After:

$ sudo ./perf stat -e cycles -a sleep 1

 Performance counter stats for 'system wide':

       841,496,603      cpu_atom/cycles/
     3,308,929,412      cpu_core/cycles/

       1.002483283 seconds time elapsed

Quoted 9 lines
Quoted 3 lines
Fixes 357b965deba9 ("perf stat: Changes to event name

uniquification")

Thanks for the fix, but there's a similar patch in the list. Please take a look.

https://lore.kernel.org/r/[email protected]

Will do, thanks!

Tom

Quoted 48 lines

Thanks,
Namhyung

Quoted 45 lines

---
 tools/perf/util/stat-display.c | 6 ++++--

 1 file changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/stat- renamed from tools/perf/util/stat-display.c +0 -0

display.c
index e65c7e9f15d1..df9f68080ec9 100644

tools/perf/util/stat-display.c +0 -0
@@ -1676,6 +1676,7 @@ static bool evlist__disable_uniquify(const
 struct evlist *evlist)


 static void evsel__set_needs_uniquify(struct evsel *counter, const struct perf_stat_config *config)
 {

tools/perf/util/stat-display.c +1 -0
+	bool hybrid = (!config->hybrid_merge &&

evsel__is_hybrid(counter));
  struct evsel *evsel;

  if (counter->merged_stat) {

tools/perf/util/stat-display.c +0 -0
@@ -1688,7 +1689,8 @@ static void evsel__set_needs_uniquify(struct

evsel *counter, const struct perf_s
  return;
  }

tools/perf/util/stat-display.c +0 -1
-	if  (counter->core.attr.type < PERF_TYPE_MAX && counter-
Quoted 1 line

core.attr.type != PERF_TYPE_RAW) {

tools/perf/util/stat-display.c +2 -0
+	if (!hybrid && counter->core.attr.type < PERF_TYPE_MAX &&
+		counter->core.attr.type != PERF_TYPE_RAW) {

  /* Legacy event, don't uniquify. */ return;
  }

tools/perf/util/stat-display.c +0 -0
@@ -1705,7 +1707,7 @@ static void evsel__set_needs_uniquify(struct

evsel *counter, const struct perf_s
  return;
  }

tools/perf/util/stat-display.c +1 -1
-	if (!config->hybrid_merge && evsel__is_hybrid(counter)) {
+	if (hybrid) {

  /* Unique hybrid counters necessary. */ counter->needs_uniquify = true; return;

Signature · 1 line
2.48.1