]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf ilist: Be tolerant of reading a metric on the wrong CPU
authorIan Rogers <irogers@google.com>
Tue, 2 Dec 2025 17:49:57 +0000 (09:49 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 3 Dec 2025 00:12:49 +0000 (16:12 -0800)
This happens on hybrid machine metrics. Be tolerant and don't cause
the ilist application to crash with an exception.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/python/ilist.py

index eb687ce9d5a6afe519593760528afaa638132287..0d757ddb479598f7664e124b0fc1938f9a346735 100755 (executable)
@@ -77,8 +77,12 @@ class Metric(TreeValue):
         return perf.parse_metrics(self.metric_name, self.metric_pmu)
 
     def value(self, evlist: perf.evlist, evsel: perf.evsel, cpu: int, thread: int) -> float:
-        val = evlist.compute_metric(self.metric_name, cpu, thread)
-        return 0 if math.isnan(val) else val
+        try:
+            val = evlist.compute_metric(self.metric_name, cpu, thread)
+            return 0 if math.isnan(val) else val
+        except:
+            # Be tolerant of failures to compute metrics on particular CPUs/threads.
+            return 0
 
 
 @dataclass