linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf stat: Fix non-uniquified hybrid legacy events
@ 2025-02-12 12:24 James Clark
  2025-02-12 17:48 ` Ian Rogers
  0 siblings, 1 reply; 7+ messages in thread
From: James Clark @ 2025-02-12 12:24 UTC (permalink / raw)
  To: linux-perf-users
  Cc: Robin.Murphy, James Clark, Peter Zijlstra, Ingo Molnar,
	Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, linux-kernel

Legacy hybrid events have attr.type == PERF_TYPE_HARDWARE, so they look
like plain legacy events if we only look at attr.type. But legacy events
should still be uniquified if they were opened on a non-legacy PMU.
Previously we looked at the PMU type to determine legacy vs hybrid
events here so revert this particular check to how it was before the
linked fixes commit.

counter->pmu doesn't need to be null checked twice, in fact it is
required for any kind of uniquification so make that a separate check.

This restores PMU names on hybrid systems and also changes "perf stat
metrics (shadow stat) test" from a FAIL back to a SKIP (on hybrid). The
test was gated on "cycles" appearing alone which doesn't happen on
here.

Before:

  $ perf stat -- true
  ...
     <not counted>      instructions:u                           (0.00%)
           162,536      instructions:u            # 0.58  insn per cycle
  ...

After:

 $ perf stat -- true
 ...
     <not counted>      cpu_atom/instructions/u                  (0.00%)
           162,541      cpu_core/instructions/u   # 0.62  insn per cycle
 ...

Fixes: 357b965deba9 ("perf stat: Changes to event name uniquification")
Signed-off-by: James Clark <james.clark@linaro.org>
---
 tools/perf/util/stat-display.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index e65c7e9f15d1..eae34ba95f59 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -1688,12 +1688,17 @@ 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 (!counter->pmu) {
+		/* evsel__uniquify_counter() uses counter->pmu for the name */
+		return;
+	}
+
+	if (counter->pmu->type < PERF_TYPE_MAX && counter->pmu->type != PERF_TYPE_RAW) {
 		/* Legacy event, don't uniquify. */
 		return;
 	}
 
-	if (counter->pmu && counter->pmu->is_core &&
+	if (counter->pmu->is_core &&
 	    counter->alternate_hw_config != PERF_COUNT_HW_MAX) {
 		/* A sysfs or json event replacing a legacy event, don't uniquify. */
 		return;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-26 14:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-12 12:24 [PATCH] perf stat: Fix non-uniquified hybrid legacy events James Clark
2025-02-12 17:48 ` Ian Rogers
2025-02-12 21:38   ` Ian Rogers
2025-02-13 12:15     ` James Clark
2025-02-14  1:27       ` Namhyung Kim
2025-02-14 10:45         ` James Clark
2025-02-26 14:57           ` James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).