Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf stat: Better hybrid support for the NMI watchdog warning

Prior to this patch evlist__has_hybrid would return false if the
processor wasn't hybrid or the evlist didn't contain any core
events. If the only PMU used by events was cpu_core then it would
true even though there are no cpu_atom events. For example:

```
$ perf stat --cputype=cpu_core -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}' true

Performance counter stats for 'true':

<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)
<not counted> cpu_core/cycles/ (0.00%)

0.001981900 seconds time elapsed

0.002311000 seconds user
0.000000000 seconds sys
```

This patch changes evlist__has_hybrid to return true only if the
evlist contains events from >1 core PMU. This means the NMI watchdog
warning is shown for the case above.

Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Dr. David Alan Gilbert <linux@treblig.org>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Levi Yun <yeoreum.yun@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Weilin Wang <weilin.wang@intel.com>
Link: https://lore.kernel.org/r/20250402201549.4090305-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
4b531377 79009388

+15 -3
+15 -3
tools/perf/util/stat-display.c
··· 822 822 return false; 823 823 } 824 824 825 - static bool evlist__has_hybrid(struct evlist *evlist) 825 + static bool evlist__has_hybrid_pmus(struct evlist *evlist) 826 826 { 827 827 struct evsel *evsel; 828 + struct perf_pmu *last_core_pmu = NULL; 828 829 829 830 if (perf_pmus__num_core_pmus() == 1) 830 831 return false; 831 832 832 833 evlist__for_each_entry(evlist, evsel) { 833 - if (evsel->core.is_pmu_core) 834 + if (evsel->core.is_pmu_core) { 835 + struct perf_pmu *pmu = evsel__find_pmu(evsel); 836 + 837 + if (pmu == last_core_pmu) 838 + continue; 839 + 840 + if (last_core_pmu == NULL) { 841 + last_core_pmu = pmu; 842 + continue; 843 + } 844 + /* A distinct core PMU. */ 834 845 return true; 846 + } 835 847 } 836 848 837 849 return false; ··· 884 872 ok = false; 885 873 886 874 if (counter->supported) { 887 - if (!evlist__has_hybrid(counter->evlist)) { 875 + if (!evlist__has_hybrid_pmus(counter->evlist)) { 888 876 config->print_free_counters_hint = 1; 889 877 if (is_mixed_hw_group(counter)) 890 878 config->print_mixed_hw_group_error = 1;