]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
perf stat: Better hybrid support for the NMI watchdog warning
authorIan Rogers <irogers@google.com>
Wed, 2 Apr 2025 20:15:45 +0000 (13:15 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 8 May 2025 15:21:40 +0000 (12:21 -0300)
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>
tools/perf/util/stat-display.c

index e852ac0d9847620cd787a706c08552f0fdcdfd97..1115efb380fb2bede268924989b8fe001bccb4d2 100644 (file)
@@ -822,16 +822,28 @@ static bool is_mixed_hw_group(struct evsel *counter)
        return false;
 }
 
-static bool evlist__has_hybrid(struct evlist *evlist)
+static bool evlist__has_hybrid_pmus(struct evlist *evlist)
 {
        struct evsel *evsel;
+       struct perf_pmu *last_core_pmu = NULL;
 
        if (perf_pmus__num_core_pmus() == 1)
                return false;
 
        evlist__for_each_entry(evlist, evsel) {
-               if (evsel->core.is_pmu_core)
+               if (evsel->core.is_pmu_core) {
+                       struct perf_pmu *pmu = evsel__find_pmu(evsel);
+
+                       if (pmu == last_core_pmu)
+                               continue;
+
+                       if (last_core_pmu == NULL) {
+                               last_core_pmu = pmu;
+                               continue;
+                       }
+                       /* A distinct core PMU. */
                        return true;
+               }
        }
 
        return false;
@@ -872,7 +884,7 @@ static void printout(struct perf_stat_config *config, struct outstate *os,
                ok = false;
 
                if (counter->supported) {
-                       if (!evlist__has_hybrid(counter->evlist)) {
+                       if (!evlist__has_hybrid_pmus(counter->evlist)) {
                                config->print_free_counters_hint = 1;
                                if (is_mixed_hw_group(counter))
                                        config->print_mixed_hw_group_error = 1;