Skip to content

Commit c9a8c34

Browse files
captain5050namhyung
authored andcommitted
perf stat: When no events, don't report an error if there is none
Events may fail to open as no supported CPUs were specified on the command line. In this case a confusing "error" message of "success" can be reported. Let's skip the error in that case. Before: ``` $ perf stat -C2048 -e cycles -- true WARNING: A requested CPU in '2048' is not supported by PMU 'cpu' (CPUs 0-7) for event 'cycles' Error: No supported events found. The sys_perf_event_open() syscall returned with 0 (Success) for event (cpu/unknown-hardware/). "dmesg | grep -i perf" may provide additional information. ``` After: ``` $ perf stat -C2048 -e cycles -- true WARNING: A requested CPU in '2048' is not supported by PMU 'cpu' (CPUs 0-7) for event 'cycles' Error: No supported events found. ``` Signed-off-by: Ian Rogers <irogers@google.com> Tested-by: Thomas Richter <tmricht@linux.ibm.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 279b5a8 commit c9a8c34

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/perf/builtin-stat.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,10 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)
924924
}
925925
}
926926
if (!has_supported_counters && !stat_config.null_run) {
927-
evsel__open_strerror(evlist__first(evsel_list), &target, open_err,
928-
msg, sizeof(msg));
927+
if (open_err) {
928+
evsel__open_strerror(evlist__first(evsel_list), &target, open_err,
929+
msg, sizeof(msg));
930+
}
929931
ui__error("No supported events found.\n%s\n", msg);
930932

931933
if (child_pid != -1)

0 commit comments

Comments
 (0)