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

perf stat: Don't size aggregation ids from user_requested_cpus

As evsels may have additional CPU terms, the user_requested_cpus may
not reflect all the CPUs requested. Use evlist->all_cpus to size the
array as that reflects all the CPUs potentially needed by the evlist.

Reviewed-by: Thomas Falcon <thomas.falcon@intel.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250719030517.1990983-4-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
ced4c249 848e7a06

+2 -5
+2 -5
tools/perf/builtin-stat.c
··· 1513 1513 * taking the highest cpu number to be the size of 1514 1514 * the aggregation translate cpumap. 1515 1515 */ 1516 - if (!perf_cpu_map__is_any_cpu_or_is_empty(evsel_list->core.user_requested_cpus)) 1517 - nr = perf_cpu_map__max(evsel_list->core.user_requested_cpus).cpu; 1518 - else 1519 - nr = 0; 1520 - stat_config.cpus_aggr_map = cpu_aggr_map__empty_new(nr + 1); 1516 + nr = perf_cpu_map__max(evsel_list->core.all_cpus).cpu + 1; 1517 + stat_config.cpus_aggr_map = cpu_aggr_map__empty_new(nr); 1521 1518 return stat_config.cpus_aggr_map ? 0 : -ENOMEM; 1522 1519 } 1523 1520