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

perf cpumap: Clean up use of perf_cpu_map__has_any_cpu_or_is_empty

Most uses of what was perf_cpu_map__empty but is now
perf_cpu_map__has_any_cpu_or_is_empty want to do something with the
CPU map if it contains CPUs. Replace uses of
perf_cpu_map__has_any_cpu_or_is_empty with other helpers so that CPUs
within the map can be handled.

Reviewed-by: James Clark <james.clark@arm.com>
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Andrew Jones <ajones@ventanamicro.com>
Cc: André Almeida <andrealmeid@igalia.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Atish Patra <atishp@rivosinc.com>
Cc: Changbin Du <changbin.du@huawei.com>
Cc: Darren Hart <dvhart@infradead.org>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Paran Lee <p4ranlee@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Steinar H. Gunderson <sesse@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: Yang Jihong <yangjihong1@huawei.com>
Cc: Yang Li <yang.lee@linux.alibaba.com>
Cc: Yanteng Si <siyanteng@loongson.cn>
Link: https://lore.kernel.org/r/20240202234057.2085863-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
3e5deb70 291dcd77

+9 -14
+1 -5
tools/perf/builtin-c2c.c
··· 2319 2319 2320 2320 nodes[node] = set; 2321 2321 2322 - /* empty node, skip */ 2323 - if (perf_cpu_map__has_any_cpu_or_is_empty(map)) 2324 - continue; 2325 - 2326 - perf_cpu_map__for_each_cpu(cpu, idx, map) { 2322 + perf_cpu_map__for_each_cpu_skip_any(cpu, idx, map) { 2327 2323 __set_bit(cpu.cpu, set); 2328 2324 2329 2325 if (WARN_ONCE(cpu2node[cpu.cpu] != -1, "node/cpu topology bug"))
+4 -5
tools/perf/builtin-stat.c
··· 1319 1319 * be the first online CPU in the cache domain else use the 1320 1320 * first online CPU of the cache domain as the ID. 1321 1321 */ 1322 - if (perf_cpu_map__has_any_cpu_or_is_empty(cpu_map)) 1322 + id = perf_cpu_map__min(cpu_map).cpu; 1323 + if (id == -1) 1323 1324 id = cpu.cpu; 1324 - else 1325 - id = perf_cpu_map__cpu(cpu_map, 0).cpu; 1326 1325 1327 1326 /* Free the perf_cpu_map used to find the cache ID */ 1328 1327 perf_cpu_map__put(cpu_map); ··· 1641 1642 * taking the highest cpu number to be the size of 1642 1643 * the aggregation translate cpumap. 1643 1644 */ 1644 - if (!perf_cpu_map__has_any_cpu_or_is_empty(evsel_list->core.user_requested_cpus)) 1645 + if (!perf_cpu_map__is_any_cpu_or_is_empty(evsel_list->core.user_requested_cpus)) 1645 1646 nr = perf_cpu_map__max(evsel_list->core.user_requested_cpus).cpu; 1646 1647 else 1647 1648 nr = 0; ··· 2333 2334 2334 2335 perf_event__read_stat_config(&stat_config, &event->stat_config); 2335 2336 2336 - if (perf_cpu_map__has_any_cpu_or_is_empty(st->cpus)) { 2337 + if (perf_cpu_map__is_empty(st->cpus)) { 2337 2338 if (st->aggr_mode != AGGR_UNSET) 2338 2339 pr_warning("warning: processing task data, aggregation mode not set\n"); 2339 2340 } else if (st->aggr_mode != AGGR_UNSET) {
+2 -2
tools/perf/util/auxtrace.c
··· 174 174 struct evlist *evlist, 175 175 struct evsel *evsel, int idx) 176 176 { 177 - bool per_cpu = !perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus); 177 + bool per_cpu = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus); 178 178 179 179 mp->mmap_needed = evsel->needs_auxtrace_mmap; 180 180 ··· 648 648 649 649 static int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int idx) 650 650 { 651 - bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus); 651 + bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu(evlist->core.user_requested_cpus); 652 652 653 653 if (per_cpu_mmaps) { 654 654 struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->core.all_cpus, idx);
+1 -1
tools/perf/util/record.c
··· 237 237 238 238 evsel = evlist__last(temp_evlist); 239 239 240 - if (!evlist || perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus)) { 240 + if (!evlist || perf_cpu_map__is_any_cpu_or_is_empty(evlist->core.user_requested_cpus)) { 241 241 struct perf_cpu_map *cpus = perf_cpu_map__new_online_cpus(); 242 242 243 243 if (cpus)
+1 -1
tools/perf/util/stat.c
··· 315 315 if (!counter->per_pkg) 316 316 return 0; 317 317 318 - if (perf_cpu_map__has_any_cpu_or_is_empty(cpus)) 318 + if (perf_cpu_map__is_any_cpu_or_is_empty(cpus)) 319 319 return 0; 320 320 321 321 if (!mask) {