Merge tag 'perf-tools-for-v5.18-2022-04-02' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull more perf tools updates from Arnaldo Carvalho de Melo:

- Avoid SEGV if core.cpus isn't set in 'perf stat'.

- Stop depending on .git files for building PERF-VERSION-FILE, used in
'perf --version', fixing some perf tools build scenarios.

- Convert tracepoint.py example to python3.

- Update UAPI header copies from the kernel sources: socket,
mman-common, msr-index, KVM, i915 and cpufeatures.

- Update copy of libbpf's hashmap.c.

- Directly return instead of using local ret variable in
evlist__create_syswide_maps(), found by coccinelle.

* tag 'perf-tools-for-v5.18-2022-04-02' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
perf python: Convert tracepoint.py example to python3
perf evlist: Directly return instead of using local ret variable
perf cpumap: More cpu map reuse by merge.
perf cpumap: Add is_subset function
perf evlist: Rename cpus to user_requested_cpus
perf tools: Stop depending on .git files for building PERF-VERSION-FILE
tools headers cpufeatures: Sync with the kernel sources
tools headers UAPI: Sync drm/i915_drm.h with the kernel sources
tools headers UAPI: Sync linux/kvm.h with the kernel sources
tools kvm headers arm64: Update KVM headers from the kernel sources
tools arch x86: Sync the msr-index.h copy with the kernel sources
tools headers UAPI: Sync asm-generic/mman-common.h with the kernel
perf beauty: Update copy of linux/socket.h with the kernel sources
perf tools: Update copy of libbpf's hashmap.c
perf stat: Avoid SEGV if core.cpus isn't set

+180 -88
+10
tools/arch/arm64/include/uapi/asm/kvm.h
··· 419 419 #define KVM_PSCI_RET_INVAL PSCI_RET_INVALID_PARAMS 420 420 #define KVM_PSCI_RET_DENIED PSCI_RET_DENIED 421 421 422 + /* arm64-specific kvm_run::system_event flags */ 423 + /* 424 + * Reset caused by a PSCI v1.1 SYSTEM_RESET2 call. 425 + * Valid only when the system event has a type of KVM_SYSTEM_EVENT_RESET. 426 + */ 427 + #define KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 (1ULL << 0) 428 + 429 + /* run->fail_entry.hardware_entry_failure_reason codes. */ 430 + #define KVM_EXIT_FAIL_ENTRY_CPU_UNSUPPORTED (1ULL << 0) 431 + 422 432 #endif 423 433 424 434 #endif /* __ARM_KVM_H__ */
+1
tools/arch/x86/include/asm/cpufeatures.h
··· 388 388 #define X86_FEATURE_TSXLDTRK (18*32+16) /* TSX Suspend Load Address Tracking */ 389 389 #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ 390 390 #define X86_FEATURE_ARCH_LBR (18*32+19) /* Intel ARCH LBR */ 391 + #define X86_FEATURE_IBT (18*32+20) /* Indirect Branch Tracking */ 391 392 #define X86_FEATURE_AMX_BF16 (18*32+22) /* AMX bf16 Support */ 392 393 #define X86_FEATURE_AVX512_FP16 (18*32+23) /* AVX512 FP16 */ 393 394 #define X86_FEATURE_AMX_TILE (18*32+24) /* AMX tile Support */
+21 -1
tools/arch/x86/include/asm/msr-index.h
··· 205 205 #define RTIT_CTL_DISRETC BIT(11) 206 206 #define RTIT_CTL_PTW_EN BIT(12) 207 207 #define RTIT_CTL_BRANCH_EN BIT(13) 208 + #define RTIT_CTL_EVENT_EN BIT(31) 209 + #define RTIT_CTL_NOTNT BIT_ULL(55) 208 210 #define RTIT_CTL_MTC_RANGE_OFFSET 14 209 211 #define RTIT_CTL_MTC_RANGE (0x0full << RTIT_CTL_MTC_RANGE_OFFSET) 210 212 #define RTIT_CTL_CYC_THRESH_OFFSET 19 ··· 362 360 #define MSR_ATOM_CORE_TURBO_RATIOS 0x0000066c 363 361 #define MSR_ATOM_CORE_TURBO_VIDS 0x0000066d 364 362 365 - 366 363 #define MSR_CORE_PERF_LIMIT_REASONS 0x00000690 367 364 #define MSR_GFX_PERF_LIMIT_REASONS 0x000006B0 368 365 #define MSR_RING_PERF_LIMIT_REASONS 0x000006B1 366 + 367 + /* Control-flow Enforcement Technology MSRs */ 368 + #define MSR_IA32_U_CET 0x000006a0 /* user mode cet */ 369 + #define MSR_IA32_S_CET 0x000006a2 /* kernel mode cet */ 370 + #define CET_SHSTK_EN BIT_ULL(0) 371 + #define CET_WRSS_EN BIT_ULL(1) 372 + #define CET_ENDBR_EN BIT_ULL(2) 373 + #define CET_LEG_IW_EN BIT_ULL(3) 374 + #define CET_NO_TRACK_EN BIT_ULL(4) 375 + #define CET_SUPPRESS_DISABLE BIT_ULL(5) 376 + #define CET_RESERVED (BIT_ULL(6) | BIT_ULL(7) | BIT_ULL(8) | BIT_ULL(9)) 377 + #define CET_SUPPRESS BIT_ULL(10) 378 + #define CET_WAIT_ENDBR BIT_ULL(11) 379 + 380 + #define MSR_IA32_PL0_SSP 0x000006a4 /* ring-0 shadow stack pointer */ 381 + #define MSR_IA32_PL1_SSP 0x000006a5 /* ring-1 shadow stack pointer */ 382 + #define MSR_IA32_PL2_SSP 0x000006a6 /* ring-2 shadow stack pointer */ 383 + #define MSR_IA32_PL3_SSP 0x000006a7 /* ring-3 shadow stack pointer */ 384 + #define MSR_IA32_INT_SSP_TAB 0x000006a8 /* exception shadow stack table */ 369 385 370 386 /* Hardware P state interface */ 371 387 #define MSR_PPERF 0x0000064e
+2
tools/include/uapi/asm-generic/mman-common.h
··· 75 75 #define MADV_POPULATE_READ 22 /* populate (prefault) page tables readable */ 76 76 #define MADV_POPULATE_WRITE 23 /* populate (prefault) page tables writable */ 77 77 78 + #define MADV_DONTNEED_LOCKED 24 /* like DONTNEED, but drop locked pages too */ 79 + 78 80 /* compatibility flags */ 79 81 #define MAP_FILE 0 80 82
+40 -5
tools/include/uapi/drm/i915_drm.h
··· 1118 1118 /** 1119 1119 * When the EXEC_OBJECT_PINNED flag is specified this is populated by 1120 1120 * the user with the GTT offset at which this object will be pinned. 1121 + * 1121 1122 * When the I915_EXEC_NO_RELOC flag is specified this must contain the 1122 1123 * presumed_offset of the object. 1124 + * 1123 1125 * During execbuffer2 the kernel populates it with the value of the 1124 1126 * current GTT offset of the object, for future presumed_offset writes. 1127 + * 1128 + * See struct drm_i915_gem_create_ext for the rules when dealing with 1129 + * alignment restrictions with I915_MEMORY_CLASS_DEVICE, on devices with 1130 + * minimum page sizes, like DG2. 1125 1131 */ 1126 1132 __u64 offset; 1127 1133 ··· 3150 3144 * 3151 3145 * The (page-aligned) allocated size for the object will be returned. 3152 3146 * 3153 - * Note that for some devices we have might have further minimum 3154 - * page-size restrictions(larger than 4K), like for device local-memory. 3155 - * However in general the final size here should always reflect any 3156 - * rounding up, if for example using the I915_GEM_CREATE_EXT_MEMORY_REGIONS 3157 - * extension to place the object in device local-memory. 3147 + * 3148 + * DG2 64K min page size implications: 3149 + * 3150 + * On discrete platforms, starting from DG2, we have to contend with GTT 3151 + * page size restrictions when dealing with I915_MEMORY_CLASS_DEVICE 3152 + * objects. Specifically the hardware only supports 64K or larger GTT 3153 + * page sizes for such memory. The kernel will already ensure that all 3154 + * I915_MEMORY_CLASS_DEVICE memory is allocated using 64K or larger page 3155 + * sizes underneath. 3156 + * 3157 + * Note that the returned size here will always reflect any required 3158 + * rounding up done by the kernel, i.e 4K will now become 64K on devices 3159 + * such as DG2. 3160 + * 3161 + * Special DG2 GTT address alignment requirement: 3162 + * 3163 + * The GTT alignment will also need to be at least 2M for such objects. 3164 + * 3165 + * Note that due to how the hardware implements 64K GTT page support, we 3166 + * have some further complications: 3167 + * 3168 + * 1) The entire PDE (which covers a 2MB virtual address range), must 3169 + * contain only 64K PTEs, i.e mixing 4K and 64K PTEs in the same 3170 + * PDE is forbidden by the hardware. 3171 + * 3172 + * 2) We still need to support 4K PTEs for I915_MEMORY_CLASS_SYSTEM 3173 + * objects. 3174 + * 3175 + * To keep things simple for userland, we mandate that any GTT mappings 3176 + * must be aligned to and rounded up to 2MB. The kernel will internally 3177 + * pad them out to the next 2MB boundary. As this only wastes virtual 3178 + * address space and avoids userland having to copy any needlessly 3179 + * complicated PDE sharing scheme (coloring) and only affects DG2, this 3180 + * is deemed to be a good compromise. 3158 3181 */ 3159 3182 __u64 size; 3160 3183 /**
+9 -2
tools/include/uapi/linux/kvm.h
··· 562 562 __u32 op; /* type of operation */ 563 563 __u64 buf; /* buffer in userspace */ 564 564 union { 565 - __u8 ar; /* the access register number */ 565 + struct { 566 + __u8 ar; /* the access register number */ 567 + __u8 key; /* access key, ignored if flag unset */ 568 + }; 566 569 __u32 sida_offset; /* offset into the sida */ 567 - __u8 reserved[32]; /* should be set to 0 */ 570 + __u8 reserved[32]; /* ignored */ 568 571 }; 569 572 }; 570 573 /* types for kvm_s390_mem_op->op */ ··· 575 572 #define KVM_S390_MEMOP_LOGICAL_WRITE 1 576 573 #define KVM_S390_MEMOP_SIDA_READ 2 577 574 #define KVM_S390_MEMOP_SIDA_WRITE 3 575 + #define KVM_S390_MEMOP_ABSOLUTE_READ 4 576 + #define KVM_S390_MEMOP_ABSOLUTE_WRITE 5 578 577 /* flags for kvm_s390_mem_op->flags */ 579 578 #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 580 579 #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) 580 + #define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2) 581 581 582 582 /* for KVM_INTERRUPT */ 583 583 struct kvm_interrupt { ··· 1143 1137 #define KVM_CAP_PPC_AIL_MODE_3 210 1144 1138 #define KVM_CAP_S390_MEM_OP_EXTENSION 211 1145 1139 #define KVM_CAP_PMU_CAPABILITY 212 1140 + #define KVM_CAP_DISABLE_QUIRKS2 213 1146 1141 1147 1142 #ifdef KVM_CAP_IRQ_ROUTING 1148 1143
+25 -10
tools/lib/perf/cpumap.c
··· 319 319 return map->nr > 0 ? map->map[map->nr - 1] : result; 320 320 } 321 321 322 + /** Is 'b' a subset of 'a'. */ 323 + bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b) 324 + { 325 + if (a == b || !b) 326 + return true; 327 + if (!a || b->nr > a->nr) 328 + return false; 329 + 330 + for (int i = 0, j = 0; i < a->nr; i++) { 331 + if (a->map[i].cpu > b->map[j].cpu) 332 + return false; 333 + if (a->map[i].cpu == b->map[j].cpu) { 334 + j++; 335 + if (j == b->nr) 336 + return true; 337 + } 338 + } 339 + return false; 340 + } 341 + 322 342 /* 323 343 * Merge two cpumaps 324 344 * ··· 355 335 int i, j, k; 356 336 struct perf_cpu_map *merged; 357 337 358 - if (!orig && !other) 359 - return NULL; 360 - if (!orig) { 361 - perf_cpu_map__get(other); 362 - return other; 338 + if (perf_cpu_map__is_subset(orig, other)) 339 + return orig; 340 + if (perf_cpu_map__is_subset(other, orig)) { 341 + perf_cpu_map__put(orig); 342 + return perf_cpu_map__get(other); 363 343 } 364 - if (!other) 365 - return orig; 366 - if (orig->nr == other->nr && 367 - !memcmp(orig->map, other->map, orig->nr * sizeof(struct perf_cpu))) 368 - return orig; 369 344 370 345 tmp_len = orig->nr + other->nr; 371 346 tmp_cpus = malloc(tmp_len * sizeof(struct perf_cpu));
+14 -14
tools/lib/perf/evlist.c
··· 41 41 */ 42 42 if (!evsel->own_cpus || evlist->has_user_cpus) { 43 43 perf_cpu_map__put(evsel->cpus); 44 - evsel->cpus = perf_cpu_map__get(evlist->cpus); 45 - } else if (!evsel->system_wide && perf_cpu_map__empty(evlist->cpus)) { 44 + evsel->cpus = perf_cpu_map__get(evlist->user_requested_cpus); 45 + } else if (!evsel->system_wide && perf_cpu_map__empty(evlist->user_requested_cpus)) { 46 46 perf_cpu_map__put(evsel->cpus); 47 - evsel->cpus = perf_cpu_map__get(evlist->cpus); 47 + evsel->cpus = perf_cpu_map__get(evlist->user_requested_cpus); 48 48 } else if (evsel->cpus != evsel->own_cpus) { 49 49 perf_cpu_map__put(evsel->cpus); 50 50 evsel->cpus = perf_cpu_map__get(evsel->own_cpus); ··· 123 123 124 124 void perf_evlist__exit(struct perf_evlist *evlist) 125 125 { 126 - perf_cpu_map__put(evlist->cpus); 126 + perf_cpu_map__put(evlist->user_requested_cpus); 127 127 perf_cpu_map__put(evlist->all_cpus); 128 128 perf_thread_map__put(evlist->threads); 129 - evlist->cpus = NULL; 129 + evlist->user_requested_cpus = NULL; 130 130 evlist->all_cpus = NULL; 131 131 evlist->threads = NULL; 132 132 fdarray__exit(&evlist->pollfd); ··· 155 155 * original reference count of 1. If that is not the case it is up to 156 156 * the caller to increase the reference count. 157 157 */ 158 - if (cpus != evlist->cpus) { 159 - perf_cpu_map__put(evlist->cpus); 160 - evlist->cpus = perf_cpu_map__get(cpus); 158 + if (cpus != evlist->user_requested_cpus) { 159 + perf_cpu_map__put(evlist->user_requested_cpus); 160 + evlist->user_requested_cpus = perf_cpu_map__get(cpus); 161 161 } 162 162 163 163 if (threads != evlist->threads) { ··· 294 294 295 295 int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) 296 296 { 297 - int nr_cpus = perf_cpu_map__nr(evlist->cpus); 297 + int nr_cpus = perf_cpu_map__nr(evlist->user_requested_cpus); 298 298 int nr_threads = perf_thread_map__nr(evlist->threads); 299 299 int nfds = 0; 300 300 struct perf_evsel *evsel; ··· 426 426 int idx, struct perf_mmap_param *mp, int cpu_idx, 427 427 int thread, int *_output, int *_output_overwrite) 428 428 { 429 - struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->cpus, cpu_idx); 429 + struct perf_cpu evlist_cpu = perf_cpu_map__cpu(evlist->user_requested_cpus, cpu_idx); 430 430 struct perf_evsel *evsel; 431 431 int revent; 432 432 ··· 536 536 struct perf_mmap_param *mp) 537 537 { 538 538 int nr_threads = perf_thread_map__nr(evlist->threads); 539 - int nr_cpus = perf_cpu_map__nr(evlist->cpus); 539 + int nr_cpus = perf_cpu_map__nr(evlist->user_requested_cpus); 540 540 int cpu, thread; 541 541 542 542 for (cpu = 0; cpu < nr_cpus; cpu++) { ··· 564 564 { 565 565 int nr_mmaps; 566 566 567 - nr_mmaps = perf_cpu_map__nr(evlist->cpus); 568 - if (perf_cpu_map__empty(evlist->cpus)) 567 + nr_mmaps = perf_cpu_map__nr(evlist->user_requested_cpus); 568 + if (perf_cpu_map__empty(evlist->user_requested_cpus)) 569 569 nr_mmaps = perf_thread_map__nr(evlist->threads); 570 570 571 571 return nr_mmaps; ··· 576 576 struct perf_mmap_param *mp) 577 577 { 578 578 struct perf_evsel *evsel; 579 - const struct perf_cpu_map *cpus = evlist->cpus; 579 + const struct perf_cpu_map *cpus = evlist->user_requested_cpus; 580 580 const struct perf_thread_map *threads = evlist->threads; 581 581 582 582 if (!ops || !ops->get || !ops->mmap)
+1
tools/lib/perf/include/internal/cpumap.h
··· 25 25 #endif 26 26 27 27 int perf_cpu_map__idx(const struct perf_cpu_map *cpus, struct perf_cpu cpu); 28 + bool perf_cpu_map__is_subset(const struct perf_cpu_map *a, const struct perf_cpu_map *b); 28 29 29 30 #endif /* __LIBPERF_INTERNAL_CPUMAP_H */
+6 -1
tools/lib/perf/include/internal/evlist.h
··· 19 19 int nr_entries; 20 20 int nr_groups; 21 21 bool has_user_cpus; 22 - struct perf_cpu_map *cpus; 22 + /** 23 + * The cpus passed from the command line or all online CPUs by 24 + * default. 25 + */ 26 + struct perf_cpu_map *user_requested_cpus; 27 + /** The union of all evsel cpu maps. */ 23 28 struct perf_cpu_map *all_cpus; 24 29 struct perf_thread_map *threads; 25 30 int nr_mmaps;
+2 -12
tools/perf/Makefile.perf
··· 691 691 $(SCRIPTS) : % : %.sh 692 692 $(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@' 693 693 694 - $(OUTPUT)PERF-VERSION-FILE: ../../.git/HEAD ../../.git/ORIG_HEAD 694 + $(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE 695 695 $(Q)$(SHELL_PATH) util/PERF-VERSION-GEN $(OUTPUT) 696 - $(Q)touch $(OUTPUT)PERF-VERSION-FILE 697 696 698 697 # These can record PERF_VERSION 699 698 perf.spec $(SCRIPTS) \ ··· 1138 1139 @echo "FEATURE-DUMP file available in $(OUTPUT)FEATURE-DUMP" 1139 1140 endif 1140 1141 1141 - # 1142 - # Trick: if ../../.git does not exist - we are building out of tree for example, 1143 - # then force version regeneration: 1144 - # 1145 - ifeq ($(wildcard ../../.git/HEAD),) 1146 - GIT-HEAD-PHONY = ../../.git/HEAD ../../.git/ORIG_HEAD 1147 - else 1148 - GIT-HEAD-PHONY = 1149 - endif 1150 1142 1151 1143 FORCE: 1152 1144 1153 1145 .PHONY: all install clean config-clean strip install-gtk 1154 1146 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell 1155 - .PHONY: $(GIT-HEAD-PHONY) TAGS tags cscope FORCE prepare 1147 + .PHONY: .FORCE-PERF-VERSION-FILE TAGS tags cscope FORCE prepare 1156 1148 .PHONY: libtraceevent_plugins archheaders 1157 1149 1158 1150 endif # force_fixdep
+4 -4
tools/perf/arch/arm/util/cs-etm.c
··· 199 199 struct evsel *evsel, u32 option) 200 200 { 201 201 int i, err = -EINVAL; 202 - struct perf_cpu_map *event_cpus = evsel->evlist->core.cpus; 202 + struct perf_cpu_map *event_cpus = evsel->evlist->core.user_requested_cpus; 203 203 struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); 204 204 205 205 /* Set option of each CPU we have */ ··· 299 299 container_of(itr, struct cs_etm_recording, itr); 300 300 struct perf_pmu *cs_etm_pmu = ptr->cs_etm_pmu; 301 301 struct evsel *evsel, *cs_etm_evsel = NULL; 302 - struct perf_cpu_map *cpus = evlist->core.cpus; 302 + struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; 303 303 bool privileged = perf_event_paranoid_check(-1); 304 304 int err = 0; 305 305 ··· 522 522 { 523 523 int i; 524 524 int etmv3 = 0, etmv4 = 0, ete = 0; 525 - struct perf_cpu_map *event_cpus = evlist->core.cpus; 525 + struct perf_cpu_map *event_cpus = evlist->core.user_requested_cpus; 526 526 struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); 527 527 528 528 /* cpu map is not empty, we have specific CPUs to work with */ ··· 713 713 u32 offset; 714 714 u64 nr_cpu, type; 715 715 struct perf_cpu_map *cpu_map; 716 - struct perf_cpu_map *event_cpus = session->evlist->core.cpus; 716 + struct perf_cpu_map *event_cpus = session->evlist->core.user_requested_cpus; 717 717 struct perf_cpu_map *online_cpus = perf_cpu_map__new(NULL); 718 718 struct cs_etm_recording *ptr = 719 719 container_of(itr, struct cs_etm_recording, itr);
+1 -1
tools/perf/arch/arm64/util/arm-spe.c
··· 144 144 container_of(itr, struct arm_spe_recording, itr); 145 145 struct perf_pmu *arm_spe_pmu = sper->arm_spe_pmu; 146 146 struct evsel *evsel, *arm_spe_evsel = NULL; 147 - struct perf_cpu_map *cpus = evlist->core.cpus; 147 + struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; 148 148 bool privileged = perf_event_paranoid_check(-1); 149 149 struct evsel *tracking_evsel; 150 150 int err;
+1 -1
tools/perf/arch/x86/util/intel-bts.c
··· 110 110 container_of(itr, struct intel_bts_recording, itr); 111 111 struct perf_pmu *intel_bts_pmu = btsr->intel_bts_pmu; 112 112 struct evsel *evsel, *intel_bts_evsel = NULL; 113 - const struct perf_cpu_map *cpus = evlist->core.cpus; 113 + const struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; 114 114 bool privileged = perf_event_paranoid_check(-1); 115 115 116 116 if (opts->auxtrace_sample_mode) {
+2 -2
tools/perf/arch/x86/util/intel-pt.c
··· 382 382 ui__warning("Intel Processor Trace: TSC not available\n"); 383 383 } 384 384 385 - per_cpu_mmaps = !perf_cpu_map__empty(session->evlist->core.cpus); 385 + per_cpu_mmaps = !perf_cpu_map__empty(session->evlist->core.user_requested_cpus); 386 386 387 387 auxtrace_info->type = PERF_AUXTRACE_INTEL_PT; 388 388 auxtrace_info->priv[INTEL_PT_PMU_TYPE] = intel_pt_pmu->type; ··· 632 632 struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu; 633 633 bool have_timing_info, need_immediate = false; 634 634 struct evsel *evsel, *intel_pt_evsel = NULL; 635 - const struct perf_cpu_map *cpus = evlist->core.cpus; 635 + const struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; 636 636 bool privileged = perf_event_paranoid_check(-1); 637 637 u64 tsc_bit; 638 638 int err;
+1 -1
tools/perf/bench/evlist-open-close.c
··· 151 151 152 152 init_stats(&time_stats); 153 153 154 - printf(" Number of cpus:\t%d\n", perf_cpu_map__nr(evlist->core.cpus)); 154 + printf(" Number of cpus:\t%d\n", perf_cpu_map__nr(evlist->core.user_requested_cpus)); 155 155 printf(" Number of threads:\t%d\n", evlist->core.threads->nr); 156 156 printf(" Number of events:\t%d (%d fds)\n", 157 157 evlist->core.nr_entries, evlist__count_evsel_fds(evlist));
+1 -1
tools/perf/builtin-ftrace.c
··· 301 301 302 302 static int set_tracing_cpu(struct perf_ftrace *ftrace) 303 303 { 304 - struct perf_cpu_map *cpumap = ftrace->evlist->core.cpus; 304 + struct perf_cpu_map *cpumap = ftrace->evlist->core.user_requested_cpus; 305 305 306 306 if (!target__has_cpu(&ftrace->target)) 307 307 return 0;
+3 -3
tools/perf/builtin-record.c
··· 987 987 int m, tm, nr_mmaps = evlist->core.nr_mmaps; 988 988 struct mmap *mmap = evlist->mmap; 989 989 struct mmap *overwrite_mmap = evlist->overwrite_mmap; 990 - struct perf_cpu_map *cpus = evlist->core.cpus; 990 + struct perf_cpu_map *cpus = evlist->core.user_requested_cpus; 991 991 992 992 thread_data->nr_mmaps = bitmap_weight(thread_data->mask->maps.bits, 993 993 thread_data->mask->maps.nbits); ··· 1881 1881 return err; 1882 1882 } 1883 1883 1884 - err = perf_event__synthesize_cpu_map(&rec->tool, rec->evlist->core.cpus, 1884 + err = perf_event__synthesize_cpu_map(&rec->tool, rec->evlist->core.user_requested_cpus, 1885 1885 process_synthesized_event, NULL); 1886 1886 if (err < 0) { 1887 1887 pr_err("Couldn't synthesize cpu map.\n"); ··· 3675 3675 static int record__init_thread_masks(struct record *rec) 3676 3676 { 3677 3677 int ret = 0; 3678 - struct perf_cpu_map *cpus = rec->evlist->core.cpus; 3678 + struct perf_cpu_map *cpus = rec->evlist->core.user_requested_cpus; 3679 3679 3680 3680 if (!record__threads_enabled(rec)) 3681 3681 return record__init_thread_default_masks(rec, cpus);
+7 -4
tools/perf/builtin-stat.c
··· 804 804 if (group) 805 805 evlist__set_leader(evsel_list); 806 806 807 - if (!cpu_map__is_dummy(evsel_list->core.cpus)) { 807 + if (!cpu_map__is_dummy(evsel_list->core.user_requested_cpus)) { 808 808 if (affinity__setup(&saved_affinity) < 0) 809 809 return -1; 810 810 affinity = &saved_affinity; ··· 1458 1458 aggr_cpu_id_get_t get_id = aggr_mode__get_aggr(stat_config.aggr_mode); 1459 1459 1460 1460 if (get_id) { 1461 - stat_config.aggr_map = cpu_aggr_map__new(evsel_list->core.cpus, 1461 + stat_config.aggr_map = cpu_aggr_map__new(evsel_list->core.user_requested_cpus, 1462 1462 get_id, /*data=*/NULL); 1463 1463 if (!stat_config.aggr_map) { 1464 1464 pr_err("cannot build %s map", aggr_mode__string[stat_config.aggr_mode]); ··· 1472 1472 * taking the highest cpu number to be the size of 1473 1473 * the aggregation translate cpumap. 1474 1474 */ 1475 - nr = perf_cpu_map__max(evsel_list->core.cpus).cpu; 1475 + if (evsel_list->core.user_requested_cpus) 1476 + nr = perf_cpu_map__max(evsel_list->core.user_requested_cpus).cpu; 1477 + else 1478 + nr = 0; 1476 1479 stat_config.cpus_aggr_map = cpu_aggr_map__empty_new(nr + 1); 1477 1480 return stat_config.cpus_aggr_map ? 0 : -ENOMEM; 1478 1481 } ··· 1630 1627 if (!get_id) 1631 1628 return 0; 1632 1629 1633 - stat_config.aggr_map = cpu_aggr_map__new(evsel_list->core.cpus, get_id, env); 1630 + stat_config.aggr_map = cpu_aggr_map__new(evsel_list->core.user_requested_cpus, get_id, env); 1634 1631 if (!stat_config.aggr_map) { 1635 1632 pr_err("cannot build %s map", aggr_mode__string[stat_config.aggr_mode]); 1636 1633 return -1;
+1 -1
tools/perf/builtin-top.c
··· 1021 1021 1022 1022 evlist__for_each_entry(evlist, counter) { 1023 1023 try_again: 1024 - if (evsel__open(counter, top->evlist->core.cpus, 1024 + if (evsel__open(counter, top->evlist->core.user_requested_cpus, 1025 1025 top->evlist->core.threads) < 0) { 1026 1026 1027 1027 /*
+2 -2
tools/perf/python/tracepoint.py
··· 34 34 if not isinstance(event, perf.sample_event): 35 35 continue 36 36 37 - print "time %u prev_comm=%s prev_pid=%d prev_prio=%d prev_state=0x%x ==> next_comm=%s next_pid=%d next_prio=%d" % ( 37 + print("time %u prev_comm=%s prev_pid=%d prev_prio=%d prev_state=0x%x ==> next_comm=%s next_pid=%d next_prio=%d" % ( 38 38 event.sample_time, 39 39 event.prev_comm, 40 40 event.prev_pid, ··· 42 42 event.prev_state, 43 43 event.next_comm, 44 44 event.next_pid, 45 - event.next_prio) 45 + event.next_prio)) 46 46 47 47 if __name__ == '__main__': 48 48 main()
+1
tools/perf/trace/beauty/include/linux/socket.h
··· 366 366 #define SOL_XDP 283 367 367 #define SOL_MPTCP 284 368 368 #define SOL_MCTP 285 369 + #define SOL_SMC 286 369 370 370 371 /* IPX options */ 371 372 #define IPX_TYPE 1
+1 -1
tools/perf/util/auxtrace.c
··· 174 174 mp->idx = idx; 175 175 176 176 if (per_cpu) { 177 - mp->cpu = perf_cpu_map__cpu(evlist->core.cpus, idx); 177 + mp->cpu = perf_cpu_map__cpu(evlist->core.user_requested_cpus, idx); 178 178 if (evlist->core.threads) 179 179 mp->tid = perf_thread_map__pid(evlist->core.threads, 0); 180 180 else
+2 -2
tools/perf/util/bpf_ftrace.c
··· 38 38 39 39 /* don't need to set cpu filter for system-wide mode */ 40 40 if (ftrace->target.cpu_list) { 41 - ncpus = perf_cpu_map__nr(ftrace->evlist->core.cpus); 41 + ncpus = perf_cpu_map__nr(ftrace->evlist->core.user_requested_cpus); 42 42 bpf_map__set_max_entries(skel->maps.cpu_filter, ncpus); 43 43 } 44 44 ··· 63 63 fd = bpf_map__fd(skel->maps.cpu_filter); 64 64 65 65 for (i = 0; i < ncpus; i++) { 66 - cpu = perf_cpu_map__cpu(ftrace->evlist->core.cpus, i).cpu; 66 + cpu = perf_cpu_map__cpu(ftrace->evlist->core.user_requested_cpus, i).cpu; 67 67 bpf_map_update_elem(fd, &cpu, &val, BPF_ANY); 68 68 } 69 69 }
+9 -9
tools/perf/util/evlist.c
··· 440 440 bool has_imm = false; 441 441 442 442 // See explanation in evlist__close() 443 - if (!cpu_map__is_dummy(evlist->core.cpus)) { 443 + if (!cpu_map__is_dummy(evlist->core.user_requested_cpus)) { 444 444 if (affinity__setup(&saved_affinity) < 0) 445 445 return; 446 446 affinity = &saved_affinity; ··· 500 500 struct affinity saved_affinity, *affinity = NULL; 501 501 502 502 // See explanation in evlist__close() 503 - if (!cpu_map__is_dummy(evlist->core.cpus)) { 503 + if (!cpu_map__is_dummy(evlist->core.user_requested_cpus)) { 504 504 if (affinity__setup(&saved_affinity) < 0) 505 505 return; 506 506 affinity = &saved_affinity; ··· 565 565 static int evlist__enable_event_thread(struct evlist *evlist, struct evsel *evsel, int thread) 566 566 { 567 567 int cpu; 568 - int nr_cpus = perf_cpu_map__nr(evlist->core.cpus); 568 + int nr_cpus = perf_cpu_map__nr(evlist->core.user_requested_cpus); 569 569 570 570 if (!evsel->core.fd) 571 571 return -EINVAL; ··· 580 580 581 581 int evlist__enable_event_idx(struct evlist *evlist, struct evsel *evsel, int idx) 582 582 { 583 - bool per_cpu_mmaps = !perf_cpu_map__empty(evlist->core.cpus); 583 + bool per_cpu_mmaps = !perf_cpu_map__empty(evlist->core.user_requested_cpus); 584 584 585 585 if (per_cpu_mmaps) 586 586 return evlist__enable_event_cpu(evlist, evsel, idx); ··· 1301 1301 struct affinity affinity; 1302 1302 1303 1303 /* 1304 - * With perf record core.cpus is usually NULL. 1304 + * With perf record core.user_requested_cpus is usually NULL. 1305 1305 * Use the old method to handle this for now. 1306 1306 */ 1307 - if (!evlist->core.cpus || cpu_map__is_dummy(evlist->core.cpus)) { 1307 + if (!evlist->core.user_requested_cpus || 1308 + cpu_map__is_dummy(evlist->core.user_requested_cpus)) { 1308 1309 evlist__for_each_entry_reverse(evlist, evsel) 1309 1310 evsel__close(evsel); 1310 1311 return; ··· 1331 1330 { 1332 1331 struct perf_cpu_map *cpus; 1333 1332 struct perf_thread_map *threads; 1334 - int err = -ENOMEM; 1335 1333 1336 1334 /* 1337 1335 * Try reading /sys/devices/system/cpu/online to get ··· 1355 1355 out_put: 1356 1356 perf_cpu_map__put(cpus); 1357 1357 out: 1358 - return err; 1358 + return -ENOMEM; 1359 1359 } 1360 1360 1361 1361 int evlist__open(struct evlist *evlist) ··· 1367 1367 * Default: one fd per CPU, all threads, aka systemwide 1368 1368 * as sys_perf_event_open(cpu = -1, thread = -1) is EINVAL 1369 1369 */ 1370 - if (evlist->core.threads == NULL && evlist->core.cpus == NULL) { 1370 + if (evlist->core.threads == NULL && evlist->core.user_requested_cpus == NULL) { 1371 1371 err = evlist__create_syswide_maps(evlist); 1372 1372 if (err < 0) 1373 1373 goto out_err;
+1 -2
tools/perf/util/hashmap.c
··· 75 75 76 76 void hashmap__free(struct hashmap *map) 77 77 { 78 - if (!map) 78 + if (IS_ERR_OR_NULL(map)) 79 79 return; 80 80 81 81 hashmap__clear(map); ··· 238 238 239 239 return true; 240 240 } 241 -
+3 -3
tools/perf/util/record.c
··· 106 106 if (opts->group) 107 107 evlist__set_leader(evlist); 108 108 109 - if (perf_cpu_map__cpu(evlist->core.cpus, 0).cpu < 0) 109 + if (perf_cpu_map__cpu(evlist->core.user_requested_cpus, 0).cpu < 0) 110 110 opts->no_inherit = true; 111 111 112 112 use_comm_exec = perf_can_comm_exec(); ··· 244 244 245 245 evsel = evlist__last(temp_evlist); 246 246 247 - if (!evlist || perf_cpu_map__empty(evlist->core.cpus)) { 247 + if (!evlist || perf_cpu_map__empty(evlist->core.user_requested_cpus)) { 248 248 struct perf_cpu_map *cpus = perf_cpu_map__new(NULL); 249 249 250 250 if (cpus) ··· 252 252 253 253 perf_cpu_map__put(cpus); 254 254 } else { 255 - cpu = perf_cpu_map__cpu(evlist->core.cpus, 0); 255 + cpu = perf_cpu_map__cpu(evlist->core.user_requested_cpus, 0); 256 256 } 257 257 258 258 while (1) {
+2 -1
tools/perf/util/sideband_evlist.c
··· 114 114 } 115 115 116 116 evlist__for_each_entry(evlist, counter) { 117 - if (evsel__open(counter, evlist->core.cpus, evlist->core.threads) < 0) 117 + if (evsel__open(counter, evlist->core.user_requested_cpus, 118 + evlist->core.threads) < 0) 118 119 goto out_delete_evlist; 119 120 } 120 121
+1 -1
tools/perf/util/stat-display.c
··· 929 929 int all_idx; 930 930 struct perf_cpu cpu; 931 931 932 - perf_cpu_map__for_each_cpu(cpu, all_idx, evlist->core.cpus) { 932 + perf_cpu_map__for_each_cpu(cpu, all_idx, evlist->core.user_requested_cpus) { 933 933 struct evsel *counter; 934 934 bool first = true; 935 935
+1 -1
tools/perf/util/synthetic-events.c
··· 2127 2127 return err; 2128 2128 } 2129 2129 2130 - err = perf_event__synthesize_cpu_map(tool, evlist->core.cpus, process, NULL); 2130 + err = perf_event__synthesize_cpu_map(tool, evlist->core.user_requested_cpus, process, NULL); 2131 2131 if (err < 0) { 2132 2132 pr_err("Couldn't synthesize thread map.\n"); 2133 2133 return err;
+5 -3
tools/perf/util/top.c
··· 95 95 96 96 if (target->cpu_list) 97 97 ret += SNPRINTF(bf + ret, size - ret, ", CPU%s: %s)", 98 - perf_cpu_map__nr(top->evlist->core.cpus) > 1 ? "s" : "", 98 + perf_cpu_map__nr(top->evlist->core.user_requested_cpus) > 1 99 + ? "s" : "", 99 100 target->cpu_list); 100 101 else { 101 102 if (target->tid) 102 103 ret += SNPRINTF(bf + ret, size - ret, ")"); 103 104 else 104 105 ret += SNPRINTF(bf + ret, size - ret, ", %d CPU%s)", 105 - perf_cpu_map__nr(top->evlist->core.cpus), 106 - perf_cpu_map__nr(top->evlist->core.cpus) > 1 ? "s" : ""); 106 + perf_cpu_map__nr(top->evlist->core.user_requested_cpus), 107 + perf_cpu_map__nr(top->evlist->core.user_requested_cpus) > 1 108 + ? "s" : ""); 107 109 } 108 110 109 111 perf_top__reset_sample_counters(top);