[PATCH v1 4/4] libperf evlist: Recompute CPU map when an evsel goes system wide
From: Ian Rogers
Date: Tue Oct 27 2026 - 13:05:40 EST
perf_evlist__go_system_wide() marks the evsel as system wide and then
propagates the evlist's maps to it. __perf_evlist__propagate_maps()
only assigns the PMU CPUs to evsel->cpus if the map is empty, but an
evsel added after the evlist's maps were created already has the user
requested CPUs propagated (e.g. the "any CPU" map of -1 in per-thread
or workload mode). Going system wide then leaves the evsel opened on
the wrong CPUs.
Drop the existing CPU map before propagating so the evsel is given all
of its PMU's CPUs, as is expected for a system wide event.
Fixes: 811082e4b668 ("perf parse-events: Support user CPUs mixed with threads/processes")
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/lib/perf/evlist.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c
index c1c5b0684eed..46de69aa5a86 100644
--- a/tools/lib/perf/evlist.c
+++ b/tools/lib/perf/evlist.c
@@ -835,7 +835,10 @@ void perf_evlist__go_system_wide(struct perf_evlist *evlist, struct perf_evsel *
{
if (!evsel->system_wide) {
evsel->system_wide = true;
- if (evlist->needs_map_propagation)
+ if (evlist->needs_map_propagation) {
+ perf_cpu_map__put(evsel->cpus);
+ evsel->cpus = NULL;
__perf_evlist__propagate_maps(evlist, evsel);
+ }
}
}
--
2.56.0.313.g2479322e68-goog