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

Configure Feed

Select the types of activity you want to include in your feed.

libperf cpumap: Rename perf_cpu_map__empty() to perf_cpu_map__has_any_cpu_or_is_empty()

The name perf_cpu_map_empty is misleading as true is also returned
when the map contains an "any" CPU (aka dummy) map.

Rename to perf_cpu_map__has_any_cpu_or_is_empty(), later changes will
(re)introduce perf_cpu_map__empty() and perf_cpu_map__has_any_cpu().

Reviewed-by: James Clark <james.clark@arm.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: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Andrew Jones <ajones@ventanamicro.com>
Cc: André Almeida <andrealmeid@igalia.com>
Cc: Athira Jajeev <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: Namhyung Kim <namhyung@kernel.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>
Cc: bpf@vger.kernel.org
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20231129060211.1890454-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
923ca62a 8f60f870

+29 -29
+1 -1
tools/lib/perf/Documentation/libperf.txt
··· 46 46 void perf_cpu_map__put(struct perf_cpu_map *map); 47 47 int perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); 48 48 int perf_cpu_map__nr(const struct perf_cpu_map *cpus); 49 - bool perf_cpu_map__empty(const struct perf_cpu_map *map); 49 + bool perf_cpu_map__has_any_cpu_or_is_empty(const struct perf_cpu_map *map); 50 50 int perf_cpu_map__max(struct perf_cpu_map *map); 51 51 bool perf_cpu_map__has(const struct perf_cpu_map *map, int cpu); 52 52
+1 -1
tools/lib/perf/cpumap.c
··· 311 311 return cpus ? __perf_cpu_map__nr(cpus) : 1; 312 312 } 313 313 314 - bool perf_cpu_map__empty(const struct perf_cpu_map *map) 314 + bool perf_cpu_map__has_any_cpu_or_is_empty(const struct perf_cpu_map *map) 315 315 { 316 316 return map ? __perf_cpu_map__cpu(map, 0).cpu == -1 : true; 317 317 }
+2 -2
tools/lib/perf/evlist.c
··· 619 619 620 620 /* One for each CPU */ 621 621 nr_mmaps = perf_cpu_map__nr(evlist->all_cpus); 622 - if (perf_cpu_map__empty(evlist->all_cpus)) { 622 + if (perf_cpu_map__has_any_cpu_or_is_empty(evlist->all_cpus)) { 623 623 /* Plus one for each thread */ 624 624 nr_mmaps += perf_thread_map__nr(evlist->threads); 625 625 /* Minus the per-thread CPU (-1) */ ··· 653 653 if (evlist->pollfd.entries == NULL && perf_evlist__alloc_pollfd(evlist) < 0) 654 654 return -ENOMEM; 655 655 656 - if (perf_cpu_map__empty(cpus)) 656 + if (perf_cpu_map__has_any_cpu_or_is_empty(cpus)) 657 657 return mmap_per_thread(evlist, ops, mp); 658 658 659 659 return mmap_per_cpu(evlist, ops, mp);
+2 -2
tools/lib/perf/include/perf/cpumap.h
··· 47 47 LIBPERF_API struct perf_cpu perf_cpu_map__cpu(const struct perf_cpu_map *cpus, int idx); 48 48 LIBPERF_API int perf_cpu_map__nr(const struct perf_cpu_map *cpus); 49 49 /** 50 - * perf_cpu_map__empty - is map either empty or the "any CPU"/dummy value. 50 + * perf_cpu_map__has_any_cpu_or_is_empty - is map either empty or has the "any CPU"/dummy value. 51 51 */ 52 - LIBPERF_API bool perf_cpu_map__empty(const struct perf_cpu_map *map); 52 + LIBPERF_API bool perf_cpu_map__has_any_cpu_or_is_empty(const struct perf_cpu_map *map); 53 53 LIBPERF_API struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map); 54 54 LIBPERF_API bool perf_cpu_map__has(const struct perf_cpu_map *map, struct perf_cpu cpu); 55 55 LIBPERF_API bool perf_cpu_map__equal(const struct perf_cpu_map *lhs,
+1 -1
tools/lib/perf/libperf.map
··· 9 9 perf_cpu_map__read; 10 10 perf_cpu_map__nr; 11 11 perf_cpu_map__cpu; 12 - perf_cpu_map__empty; 12 + perf_cpu_map__has_any_cpu_or_is_empty; 13 13 perf_cpu_map__max; 14 14 perf_cpu_map__has; 15 15 perf_thread_map__new_array;
+5 -5
tools/perf/arch/arm/util/cs-etm.c
··· 211 211 * program can run on any CPUs in this case, thus don't skip 212 212 * validation. 213 213 */ 214 - if (!perf_cpu_map__empty(event_cpus) && 214 + if (!perf_cpu_map__has_any_cpu_or_is_empty(event_cpus) && 215 215 !perf_cpu_map__has(event_cpus, cpu)) 216 216 continue; 217 217 ··· 435 435 * Also the case of per-cpu mmaps, need the contextID in order to be notified 436 436 * when a context switch happened. 437 437 */ 438 - if (!perf_cpu_map__empty(cpus)) { 438 + if (!perf_cpu_map__has_any_cpu_or_is_empty(cpus)) { 439 439 evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel, 440 440 "timestamp", 1); 441 441 evsel__set_config_if_unset(cs_etm_pmu, cs_etm_evsel, ··· 461 461 evsel->core.attr.sample_period = 1; 462 462 463 463 /* In per-cpu case, always need the time of mmap events etc */ 464 - if (!perf_cpu_map__empty(cpus)) 464 + if (!perf_cpu_map__has_any_cpu_or_is_empty(cpus)) 465 465 evsel__set_sample_bit(evsel, TIME); 466 466 467 467 err = cs_etm_validate_config(itr, cs_etm_evsel); ··· 539 539 struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); 540 540 541 541 /* cpu map is not empty, we have specific CPUs to work with */ 542 - if (!perf_cpu_map__empty(event_cpus)) { 542 + if (!perf_cpu_map__has_any_cpu_or_is_empty(event_cpus)) { 543 543 for (i = 0; i < cpu__max_cpu().cpu; i++) { 544 544 struct perf_cpu cpu = { .cpu = i, }; 545 545 ··· 814 814 return -EINVAL; 815 815 816 816 /* If the cpu_map is empty all online CPUs are involved */ 817 - if (perf_cpu_map__empty(event_cpus)) { 817 + if (perf_cpu_map__has_any_cpu_or_is_empty(event_cpus)) { 818 818 cpu_map = online_cpus; 819 819 } else { 820 820 /* Make sure all specified CPUs are online */
+2 -2
tools/perf/arch/arm64/util/arm-spe.c
··· 232 232 * In the case of per-cpu mmaps, sample CPU for AUX event; 233 233 * also enable the timestamp tracing for samples correlation. 234 234 */ 235 - if (!perf_cpu_map__empty(cpus)) { 235 + if (!perf_cpu_map__has_any_cpu_or_is_empty(cpus)) { 236 236 evsel__set_sample_bit(arm_spe_evsel, CPU); 237 237 evsel__set_config_if_unset(arm_spe_pmu, arm_spe_evsel, 238 238 "ts_enable", 1); ··· 265 265 tracking_evsel->core.attr.sample_period = 1; 266 266 267 267 /* In per-cpu case, always need the time of mmap events etc */ 268 - if (!perf_cpu_map__empty(cpus)) { 268 + if (!perf_cpu_map__has_any_cpu_or_is_empty(cpus)) { 269 269 evsel__set_sample_bit(tracking_evsel, TIME); 270 270 evsel__set_sample_bit(tracking_evsel, CPU); 271 271
+2 -2
tools/perf/arch/x86/util/intel-bts.c
··· 143 143 if (!opts->full_auxtrace) 144 144 return 0; 145 145 146 - if (opts->full_auxtrace && !perf_cpu_map__empty(cpus)) { 146 + if (opts->full_auxtrace && !perf_cpu_map__has_any_cpu_or_is_empty(cpus)) { 147 147 pr_err(INTEL_BTS_PMU_NAME " does not support per-cpu recording\n"); 148 148 return -EINVAL; 149 149 } ··· 224 224 * In the case of per-cpu mmaps, we need the CPU on the 225 225 * AUX event. 226 226 */ 227 - if (!perf_cpu_map__empty(cpus)) 227 + if (!perf_cpu_map__has_any_cpu_or_is_empty(cpus)) 228 228 evsel__set_sample_bit(intel_bts_evsel, CPU); 229 229 } 230 230
+5 -5
tools/perf/arch/x86/util/intel-pt.c
··· 369 369 ui__warning("Intel Processor Trace: TSC not available\n"); 370 370 } 371 371 372 - per_cpu_mmaps = !perf_cpu_map__empty(session->evlist->core.user_requested_cpus); 372 + per_cpu_mmaps = !perf_cpu_map__has_any_cpu_or_is_empty(session->evlist->core.user_requested_cpus); 373 373 374 374 auxtrace_info->type = PERF_AUXTRACE_INTEL_PT; 375 375 auxtrace_info->priv[INTEL_PT_PMU_TYPE] = intel_pt_pmu->type; ··· 774 774 * Per-cpu recording needs sched_switch events to distinguish different 775 775 * threads. 776 776 */ 777 - if (have_timing_info && !perf_cpu_map__empty(cpus) && 777 + if (have_timing_info && !perf_cpu_map__has_any_cpu_or_is_empty(cpus) && 778 778 !record_opts__no_switch_events(opts)) { 779 779 if (perf_can_record_switch_events()) { 780 780 bool cpu_wide = !target__none(&opts->target) && ··· 832 832 * In the case of per-cpu mmaps, we need the CPU on the 833 833 * AUX event. 834 834 */ 835 - if (!perf_cpu_map__empty(cpus)) 835 + if (!perf_cpu_map__has_any_cpu_or_is_empty(cpus)) 836 836 evsel__set_sample_bit(intel_pt_evsel, CPU); 837 837 } 838 838 ··· 858 858 tracking_evsel->immediate = true; 859 859 860 860 /* In per-cpu case, always need the time of mmap events etc */ 861 - if (!perf_cpu_map__empty(cpus)) { 861 + if (!perf_cpu_map__has_any_cpu_or_is_empty(cpus)) { 862 862 evsel__set_sample_bit(tracking_evsel, TIME); 863 863 /* And the CPU for switch events */ 864 864 evsel__set_sample_bit(tracking_evsel, CPU); ··· 870 870 * Warn the user when we do not have enough information to decode i.e. 871 871 * per-cpu with no sched_switch (except workload-only). 872 872 */ 873 - if (!ptr->have_sched_switch && !perf_cpu_map__empty(cpus) && 873 + if (!ptr->have_sched_switch && !perf_cpu_map__has_any_cpu_or_is_empty(cpus) && 874 874 !target__none(&opts->target) && 875 875 !intel_pt_evsel->core.attr.exclude_user) 876 876 ui__warning("Intel Processor Trace decoding will not be possible except for kernel tracing!\n");
+1 -1
tools/perf/builtin-c2c.c
··· 2320 2320 nodes[node] = set; 2321 2321 2322 2322 /* empty node, skip */ 2323 - if (perf_cpu_map__empty(map)) 2323 + if (perf_cpu_map__has_any_cpu_or_is_empty(map)) 2324 2324 continue; 2325 2325 2326 2326 perf_cpu_map__for_each_cpu(cpu, idx, map) {
+3 -3
tools/perf/builtin-stat.c
··· 1316 1316 * be the first online CPU in the cache domain else use the 1317 1317 * first online CPU of the cache domain as the ID. 1318 1318 */ 1319 - if (perf_cpu_map__empty(cpu_map)) 1319 + if (perf_cpu_map__has_any_cpu_or_is_empty(cpu_map)) 1320 1320 id = cpu.cpu; 1321 1321 else 1322 1322 id = perf_cpu_map__cpu(cpu_map, 0).cpu; ··· 1622 1622 * taking the highest cpu number to be the size of 1623 1623 * the aggregation translate cpumap. 1624 1624 */ 1625 - if (!perf_cpu_map__empty(evsel_list->core.user_requested_cpus)) 1625 + if (!perf_cpu_map__has_any_cpu_or_is_empty(evsel_list->core.user_requested_cpus)) 1626 1626 nr = perf_cpu_map__max(evsel_list->core.user_requested_cpus).cpu; 1627 1627 else 1628 1628 nr = 0; ··· 2289 2289 2290 2290 perf_event__read_stat_config(&stat_config, &event->stat_config); 2291 2291 2292 - if (perf_cpu_map__empty(st->cpus)) { 2292 + if (perf_cpu_map__has_any_cpu_or_is_empty(st->cpus)) { 2293 2293 if (st->aggr_mode != AGGR_UNSET) 2294 2294 pr_warning("warning: processing task data, aggregation mode not set\n"); 2295 2295 } 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__empty(evlist->core.user_requested_cpus); 177 + bool per_cpu = !perf_cpu_map__has_any_cpu_or_is_empty(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__empty(evlist->core.user_requested_cpus); 651 + bool per_cpu_mmaps = !perf_cpu_map__has_any_cpu_or_is_empty(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__empty(evlist->core.user_requested_cpus)) { 240 + if (!evlist || perf_cpu_map__has_any_cpu_or_is_empty(evlist->core.user_requested_cpus)) { 241 241 struct perf_cpu_map *cpus = perf_cpu_map__new(NULL); 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__empty(cpus)) 318 + if (perf_cpu_map__has_any_cpu_or_is_empty(cpus)) 319 319 return 0; 320 320 321 321 if (!mask) {