linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] perf stat: Additional verbose details for <not supported> events
@ 2025-10-05 18:14 Ian Rogers
  2025-10-08  8:43 ` Namhyung Kim
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Rogers @ 2025-10-05 18:14 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
	Adrian Hunter, linux-perf-users, linux-kernel

If an event shows as "<not supported>" in perf stat output, in verbose
mode add the strerror output to help diagnose the issue.

Consider:
```
$ perf stat -e cycles,data_read,instructions true

 Performance counter stats for 'true':

           357,457      cycles:u
   <not supported> MiB  data_read:u
           156,182      instructions:u                   #    0.44  insn per cycle

       0.001250315 seconds time elapsed

       0.001283000 seconds user
       0.000000000 seconds sys
```

To understand why the data_read uncore event failed, with this change:
```
$ perf stat -v -e cycles,data_read,instructions true
Using CPUID GenuineIntel-6-8D-1
cycles -> cpu/cycles/
data_read -> uncore_imc_free_running_0/data_read/
data_read -> uncore_imc_free_running_1/data_read/
instructions -> cpu/instructions/
Control descriptor is not initialized
Warning:
kernel.perf_event_paranoid=2, trying to fall back to excluding kernel and hypervisor  samples
Warning:
kernel.perf_event_paranoid=2, trying to fall back to excluding kernel and hypervisor  samples
Warning:
kernel.perf_event_paranoid=2, trying to fall back to excluding kernel and hypervisor  samples
Warning:
data_read:u event is not supported by the kernel.
Invalid event (data_read:u) in per-thread mode, enable system wide with '-a'.
Warning:
kernel.perf_event_paranoid=2, trying to fall back to excluding kernel and hypervisor  samples
Warning:
data_read:u event is not supported by the kernel.
Invalid event (data_read:u) in per-thread mode, enable system wide with '-a'.
cycles:u: 351621 362833 362833
failed to read counter data_read:u
failed to read counter data_read:u
instructions:u: 156184 362833 362833

 Performance counter stats for 'true':

           351,621      cycles:u
   <not supported> MiB  data_read:u
           156,184      instructions:u                   #    0.44  insn per cycle

       0.001584472 seconds time elapsed

       0.001811000 seconds user
       0.000000000 seconds sys
```
where without this change only "data_read:u event is not supported by
the kernel." is shown.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/builtin-stat.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 7006f848f87a..84e06ec09cc2 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -624,8 +624,9 @@ static enum counter_recovery stat_handle_error(struct evsel *counter, int err)
 	 */
 	if (err == EINVAL || err == ENOSYS || err == ENOENT || err == ENXIO) {
 		if (verbose > 0) {
-			ui__warning("%s event is not supported by the kernel.\n",
-				    evsel__name(counter));
+			evsel__open_strerror(counter, &target, err, msg, sizeof(msg));
+			ui__warning("%s event is not supported by the kernel.\n%s\n",
+				    evsel__name(counter), msg);
 		}
 		return COUNTER_SKIP;
 	}
@@ -649,10 +650,11 @@ static enum counter_recovery stat_handle_error(struct evsel *counter, int err)
 		}
 	}
 	if (verbose > 0) {
+		evsel__open_strerror(counter, &target, err, msg, sizeof(msg));
 		ui__warning(err == EOPNOTSUPP
-			? "%s event is not supported by the kernel.\n"
-			: "skipping event %s that kernel failed to open.\n",
-			evsel__name(counter));
+			? "%s event is not supported by the kernel.\n%s\n"
+			: "skipping event %s that kernel failed to open.\n%s\n",
+			evsel__name(counter), msg);
 	}
 	return COUNTER_SKIP;
 }
-- 
2.51.0.618.g983fd99d29-goog


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

end of thread, other threads:[~2025-10-14 14:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-05 18:14 [PATCH v1] perf stat: Additional verbose details for <not supported> events Ian Rogers
2025-10-08  8:43 ` Namhyung Kim
2025-10-08 16:31   ` Ian Rogers
2025-10-09  5:51     ` Namhyung Kim
2025-10-09 13:31       ` Ian Rogers
2025-10-14 14:04         ` Namhyung Kim

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).