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

Merge tag 'perf-tools-fixes-for-v6.3-1-2023-03-09' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux

Pull perf tools fixes from Arnaldo Carvalho de Melo:

- Add Adrian Hunter to MAINTAINERS as a perf tools reviewer

- Sync various tools/ copies of kernel headers with the kernel sources,
this time trying to avoid first merging with upstream to then update
but instead copy from upstream so that a merge is avoided and the end
result after merging this pull request is the one expected,
tools/perf/check-headers.sh (mostly) happy, less warnings while
building tools/perf/

- Fix counting when initial delay configured by setting
perf_attr.enable_on_exec when starting workloads from the perf
command line

- Don't avoid emitting a PERF_RECORD_MMAP2 in 'perf inject
--buildid-all' when that record comes with a build-id, otherwise we
end up not being able to resolve symbols

- Don't use comma as the CSV output separator the "stat+csv_output"
test, as comma can appear on some tests as a modifier for an event,
use @ instead, ditto for the JSON linter test

- The offcpu test was looking for some bits being set on
task_struct->prev_state without masking other bits not important for
this specific 'perf test', fix it

* tag 'perf-tools-fixes-for-v6.3-1-2023-03-09' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
perf tools: Add Adrian Hunter to MAINTAINERS as a reviewer
tools headers UAPI: Sync linux/perf_event.h with the kernel sources
tools headers x86 cpufeatures: Sync with the kernel sources
tools include UAPI: Sync linux/vhost.h with the kernel sources
tools arch x86: Sync the msr-index.h copy with the kernel sources
tools headers kvm: Sync uapi/{asm/linux} kvm.h headers with the kernel sources
tools include UAPI: Synchronize linux/fcntl.h with the kernel sources
tools headers: Synchronize {linux,vdso}/bits.h with the kernel sources
tools headers UAPI: Sync linux/prctl.h with the kernel sources
tools headers: Update the copy of x86's mem{cpy,set}_64.S used in 'perf bench'
perf stat: Fix counting when initial delay configured
tools headers svm: Sync svm headers with the kernel sources
perf test: Avoid counting commas in json linter
perf tests stat+csv_output: Switch CSV separator to @
perf inject: Fix --buildid-all not to eat up MMAP2
tools arch x86: Sync the msr-index.h copy with the kernel sources
perf test: Fix offcpu test prev_state check

+154 -54
+1
MAINTAINERS
··· 16391 16391 R: Jiri Olsa <jolsa@kernel.org> 16392 16392 R: Namhyung Kim <namhyung@kernel.org> 16393 16393 R: Ian Rogers <irogers@google.com> 16394 + R: Adrian Hunter <adrian.hunter@intel.com> 16394 16395 L: linux-perf-users@vger.kernel.org 16395 16396 L: linux-kernel@vger.kernel.org 16396 16397 S: Supported
+1
tools/arch/arm64/include/uapi/asm/kvm.h
··· 109 109 #define KVM_ARM_VCPU_SVE 4 /* enable SVE for this CPU */ 110 110 #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication */ 111 111 #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication */ 112 + #define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */ 112 113 113 114 struct kvm_vcpu_init { 114 115 __u32 target;
+1 -1
tools/arch/x86/include/asm/cpufeatures.h
··· 13 13 /* 14 14 * Defines x86 CPU feature bits 15 15 */ 16 - #define NCAPINTS 20 /* N 32-bit words worth of info */ 16 + #define NCAPINTS 21 /* N 32-bit words worth of info */ 17 17 #define NBUGINTS 1 /* N 32-bit bug flags */ 18 18 19 19 /*
+2 -1
tools/arch/x86/include/asm/disabled-features.h
··· 124 124 #define DISABLED_MASK17 0 125 125 #define DISABLED_MASK18 0 126 126 #define DISABLED_MASK19 0 127 - #define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) 127 + #define DISABLED_MASK20 0 128 + #define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21) 128 129 129 130 #endif /* _ASM_X86_DISABLED_FEATURES_H */
+31
tools/arch/x86/include/asm/msr-index.h
··· 25 25 #define _EFER_SVME 12 /* Enable virtualization */ 26 26 #define _EFER_LMSLE 13 /* Long Mode Segment Limit Enable */ 27 27 #define _EFER_FFXSR 14 /* Enable Fast FXSAVE/FXRSTOR */ 28 + #define _EFER_AUTOIBRS 21 /* Enable Automatic IBRS */ 28 29 29 30 #define EFER_SCE (1<<_EFER_SCE) 30 31 #define EFER_LME (1<<_EFER_LME) ··· 34 33 #define EFER_SVME (1<<_EFER_SVME) 35 34 #define EFER_LMSLE (1<<_EFER_LMSLE) 36 35 #define EFER_FFXSR (1<<_EFER_FFXSR) 36 + #define EFER_AUTOIBRS (1<<_EFER_AUTOIBRS) 37 37 38 38 /* Intel MSRs. Some also available on other CPUs */ 39 39 ··· 50 48 #define SPEC_CTRL_SSBD BIT(SPEC_CTRL_SSBD_SHIFT) /* Speculative Store Bypass Disable */ 51 49 #define SPEC_CTRL_RRSBA_DIS_S_SHIFT 6 /* Disable RRSBA behavior */ 52 50 #define SPEC_CTRL_RRSBA_DIS_S BIT(SPEC_CTRL_RRSBA_DIS_S_SHIFT) 51 + 52 + /* A mask for bits which the kernel toggles when controlling mitigations */ 53 + #define SPEC_CTRL_MITIGATIONS_MASK (SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_SSBD \ 54 + | SPEC_CTRL_RRSBA_DIS_S) 53 55 54 56 #define MSR_IA32_PRED_CMD 0x00000049 /* Prediction Command */ 55 57 #define PRED_CMD_IBPB BIT(0) /* Indirect Branch Prediction Barrier */ ··· 194 188 #define MSR_TURBO_RATIO_LIMIT 0x000001ad 195 189 #define MSR_TURBO_RATIO_LIMIT1 0x000001ae 196 190 #define MSR_TURBO_RATIO_LIMIT2 0x000001af 191 + 192 + #define MSR_SNOOP_RSP_0 0x00001328 193 + #define MSR_SNOOP_RSP_1 0x00001329 197 194 198 195 #define MSR_LBR_SELECT 0x000001c8 199 196 #define MSR_LBR_TOS 0x000001c9 ··· 574 565 #define MSR_AMD64_SEV_ENABLED BIT_ULL(MSR_AMD64_SEV_ENABLED_BIT) 575 566 #define MSR_AMD64_SEV_ES_ENABLED BIT_ULL(MSR_AMD64_SEV_ES_ENABLED_BIT) 576 567 #define MSR_AMD64_SEV_SNP_ENABLED BIT_ULL(MSR_AMD64_SEV_SNP_ENABLED_BIT) 568 + 569 + /* SNP feature bits enabled by the hypervisor */ 570 + #define MSR_AMD64_SNP_VTOM BIT_ULL(3) 571 + #define MSR_AMD64_SNP_REFLECT_VC BIT_ULL(4) 572 + #define MSR_AMD64_SNP_RESTRICTED_INJ BIT_ULL(5) 573 + #define MSR_AMD64_SNP_ALT_INJ BIT_ULL(6) 574 + #define MSR_AMD64_SNP_DEBUG_SWAP BIT_ULL(7) 575 + #define MSR_AMD64_SNP_PREVENT_HOST_IBS BIT_ULL(8) 576 + #define MSR_AMD64_SNP_BTB_ISOLATION BIT_ULL(9) 577 + #define MSR_AMD64_SNP_VMPL_SSS BIT_ULL(10) 578 + #define MSR_AMD64_SNP_SECURE_TSC BIT_ULL(11) 579 + #define MSR_AMD64_SNP_VMGEXIT_PARAM BIT_ULL(12) 580 + #define MSR_AMD64_SNP_IBS_VIRT BIT_ULL(14) 581 + #define MSR_AMD64_SNP_VMSA_REG_PROTECTION BIT_ULL(16) 582 + #define MSR_AMD64_SNP_SMT_PROTECTION BIT_ULL(17) 583 + 584 + /* SNP feature bits reserved for future use. */ 585 + #define MSR_AMD64_SNP_RESERVED_BIT13 BIT_ULL(13) 586 + #define MSR_AMD64_SNP_RESERVED_BIT15 BIT_ULL(15) 587 + #define MSR_AMD64_SNP_RESERVED_MASK GENMASK_ULL(63, 18) 577 588 578 589 #define MSR_AMD64_VIRT_SPEC_CTRL 0xc001011f 579 590 ··· 1090 1061 1091 1062 /* - AMD: */ 1092 1063 #define MSR_IA32_MBA_BW_BASE 0xc0000200 1064 + #define MSR_IA32_SMBA_BW_BASE 0xc0000280 1065 + #define MSR_IA32_EVT_CFG_BASE 0xc0000400 1093 1066 1094 1067 /* MSR_IA32_VMX_MISC bits */ 1095 1068 #define MSR_IA32_VMX_MISC_INTEL_PT (1ULL << 14)
+2 -1
tools/arch/x86/include/asm/required-features.h
··· 98 98 #define REQUIRED_MASK17 0 99 99 #define REQUIRED_MASK18 0 100 100 #define REQUIRED_MASK19 0 101 - #define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 20) 101 + #define REQUIRED_MASK20 0 102 + #define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 21) 102 103 103 104 #endif /* _ASM_X86_REQUIRED_FEATURES_H */
+32 -2
tools/arch/x86/include/uapi/asm/kvm.h
··· 9 9 10 10 #include <linux/types.h> 11 11 #include <linux/ioctl.h> 12 + #include <linux/stddef.h> 12 13 13 14 #define KVM_PIO_PAGE_OFFSET 1 14 15 #define KVM_COALESCED_MMIO_PAGE_OFFSET 2 ··· 508 507 * KVM_{GET,PUT}_NESTED_STATE ioctl values. 509 508 */ 510 509 union { 511 - struct kvm_vmx_nested_state_data vmx[0]; 512 - struct kvm_svm_nested_state_data svm[0]; 510 + __DECLARE_FLEX_ARRAY(struct kvm_vmx_nested_state_data, vmx); 511 + __DECLARE_FLEX_ARRAY(struct kvm_svm_nested_state_data, svm); 513 512 } data; 514 513 }; 515 514 ··· 525 524 526 525 #define KVM_PMU_EVENT_ALLOW 0 527 526 #define KVM_PMU_EVENT_DENY 1 527 + 528 + #define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0) 529 + #define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS) 530 + 531 + /* 532 + * Masked event layout. 533 + * Bits Description 534 + * ---- ----------- 535 + * 7:0 event select (low bits) 536 + * 15:8 umask match 537 + * 31:16 unused 538 + * 35:32 event select (high bits) 539 + * 36:54 unused 540 + * 55 exclude bit 541 + * 63:56 umask mask 542 + */ 543 + 544 + #define KVM_PMU_ENCODE_MASKED_ENTRY(event_select, mask, match, exclude) \ 545 + (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | \ 546 + (((mask) & 0xFFULL) << 56) | \ 547 + (((match) & 0xFFULL) << 8) | \ 548 + ((__u64)(!!(exclude)) << 55)) 549 + 550 + #define KVM_PMU_MASKED_ENTRY_EVENT_SELECT \ 551 + (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32)) 552 + #define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56)) 553 + #define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8)) 554 + #define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55)) 555 + #define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56) 528 556 529 557 /* for KVM_{GET,SET,HAS}_DEVICE_ATTR */ 530 558 #define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
+6
tools/arch/x86/include/uapi/asm/svm.h
··· 116 116 #define SVM_VMGEXIT_AP_CREATE 1 117 117 #define SVM_VMGEXIT_AP_DESTROY 2 118 118 #define SVM_VMGEXIT_HV_FEATURES 0x8000fffd 119 + #define SVM_VMGEXIT_TERM_REQUEST 0x8000fffe 120 + #define SVM_VMGEXIT_TERM_REASON(reason_set, reason_code) \ 121 + /* SW_EXITINFO1[3:0] */ \ 122 + (((((u64)reason_set) & 0xf)) | \ 123 + /* SW_EXITINFO1[11:4] */ \ 124 + ((((u64)reason_code) & 0xff) << 4)) 119 125 #define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff 120 126 121 127 /* Exit code reserved for hypervisor/software use */
+2 -3
tools/arch/x86/lib/memcpy_64.S
··· 7 7 #include <asm/alternative.h> 8 8 #include <asm/export.h> 9 9 10 - .pushsection .noinstr.text, "ax" 10 + .section .noinstr.text, "ax" 11 11 12 12 /* 13 13 * We build a jump to memcpy_orig by default which gets NOPped out on ··· 42 42 SYM_FUNC_END(__memcpy) 43 43 EXPORT_SYMBOL(__memcpy) 44 44 45 - SYM_FUNC_ALIAS_WEAK(memcpy, __memcpy) 45 + SYM_FUNC_ALIAS(memcpy, __memcpy) 46 46 EXPORT_SYMBOL(memcpy) 47 47 48 48 /* ··· 183 183 RET 184 184 SYM_FUNC_END(memcpy_orig) 185 185 186 - .popsection
+3 -1
tools/arch/x86/lib/memset_64.S
··· 6 6 #include <asm/alternative.h> 7 7 #include <asm/export.h> 8 8 9 + .section .noinstr.text, "ax" 10 + 9 11 /* 10 12 * ISO C memset - set a memory block to a byte value. This function uses fast 11 13 * string to get better performance than the original function. The code is ··· 45 43 SYM_FUNC_END(__memset) 46 44 EXPORT_SYMBOL(__memset) 47 45 48 - SYM_FUNC_ALIAS_WEAK(memset, __memset) 46 + SYM_FUNC_ALIAS(memset, __memset) 49 47 EXPORT_SYMBOL(memset) 50 48 51 49 /*
-1
tools/include/linux/bits.h
··· 6 6 #include <vdso/bits.h> 7 7 #include <asm/bitsperlong.h> 8 8 9 - #define BIT_ULL(nr) (ULL(1) << (nr)) 10 9 #define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG)) 11 10 #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) 12 11 #define BIT_ULL_MASK(nr) (ULL(1) << ((nr) % BITS_PER_LONG_LONG))
+1
tools/include/uapi/linux/fcntl.h
··· 43 43 #define F_SEAL_GROW 0x0004 /* prevent file from growing */ 44 44 #define F_SEAL_WRITE 0x0008 /* prevent writes */ 45 45 #define F_SEAL_FUTURE_WRITE 0x0010 /* prevent future writes while mapped */ 46 + #define F_SEAL_EXEC 0x0020 /* prevent chmod modifying exec bits */ 46 47 /* (1U << 31) is reserved for signed error codes */ 47 48 48 49 /*
+9
tools/include/uapi/linux/kvm.h
··· 583 583 struct { 584 584 __u8 ar; /* the access register number */ 585 585 __u8 key; /* access key, ignored if flag unset */ 586 + __u8 pad1[6]; /* ignored */ 587 + __u64 old_addr; /* ignored if cmpxchg flag unset */ 586 588 }; 587 589 __u32 sida_offset; /* offset into the sida */ 588 590 __u8 reserved[32]; /* ignored */ ··· 597 595 #define KVM_S390_MEMOP_SIDA_WRITE 3 598 596 #define KVM_S390_MEMOP_ABSOLUTE_READ 4 599 597 #define KVM_S390_MEMOP_ABSOLUTE_WRITE 5 598 + #define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6 599 + 600 600 /* flags for kvm_s390_mem_op->flags */ 601 601 #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) 602 602 #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) 603 603 #define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2) 604 + 605 + /* flags specifying extension support via KVM_CAP_S390_MEM_OP_EXTENSION */ 606 + #define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0) 607 + #define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1) 604 608 605 609 /* for KVM_INTERRUPT */ 606 610 struct kvm_interrupt { ··· 1183 1175 #define KVM_CAP_DIRTY_LOG_RING_ACQ_REL 223 1184 1176 #define KVM_CAP_S390_PROTECTED_ASYNC_DISABLE 224 1185 1177 #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 1178 + #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226 1186 1179 1187 1180 #ifdef KVM_CAP_IRQ_ROUTING 1188 1181
+3
tools/include/uapi/linux/perf_event.h
··· 374 374 #define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */ 375 375 #define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */ 376 376 #define PERF_ATTR_SIZE_VER7 128 /* add: sig_data */ 377 + #define PERF_ATTR_SIZE_VER8 136 /* add: config3 */ 377 378 378 379 /* 379 380 * Hardware event_id to monitor via a performance monitoring event: ··· 516 515 * truncated accordingly on 32 bit architectures. 517 516 */ 518 517 __u64 sig_data; 518 + 519 + __u64 config3; /* extension of config2 */ 519 520 }; 520 521 521 522 /*
+6
tools/include/uapi/linux/prctl.h
··· 281 281 # define PR_SME_VL_LEN_MASK 0xffff 282 282 # define PR_SME_VL_INHERIT (1 << 17) /* inherit across exec */ 283 283 284 + /* Memory deny write / execute */ 285 + #define PR_SET_MDWE 65 286 + # define PR_MDWE_REFUSE_EXEC_GAIN 1 287 + 288 + #define PR_GET_MDWE 66 289 + 284 290 #define PR_SET_VMA 0x53564d41 285 291 # define PR_SET_VMA_ANON_NAME 0 286 292
+8
tools/include/uapi/linux/vhost.h
··· 180 180 */ 181 181 #define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D) 182 182 183 + /* Resume a device so it can resume processing virtqueue requests 184 + * 185 + * After the return of this ioctl the device will have restored all the 186 + * necessary states and it is fully operational to continue processing the 187 + * virtqueue descriptors. 188 + */ 189 + #define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E) 190 + 183 191 #endif
+1
tools/include/vdso/bits.h
··· 5 5 #include <vdso/const.h> 6 6 7 7 #define BIT(nr) (UL(1) << (nr)) 8 + #define BIT_ULL(nr) (ULL(1) << (nr)) 8 9 9 10 #endif /* __VDSO_BITS_H */
+1
tools/perf/builtin-inject.c
··· 538 538 dso->hit = 1; 539 539 } 540 540 dso__put(dso); 541 + perf_event__repipe(tool, event, sample, machine); 541 542 return 0; 542 543 } 543 544
+5 -10
tools/perf/builtin-stat.c
··· 539 539 return err; 540 540 } 541 541 542 - /* 543 - * We need to enable counters only if: 544 - * - we don't have tracee (attaching to task or cpu) 545 - * - we have initial delay configured 546 - */ 547 - if (!target__none(&target)) { 542 + if (!target__enable_on_exec(&target)) { 548 543 if (!all_counters_use_bpf) 549 544 evlist__enable(evsel_list); 550 545 } ··· 909 914 return err; 910 915 } 911 916 912 - if (stat_config.initial_delay) { 917 + if (target.initial_delay) { 913 918 pr_info(EVLIST_DISABLED_MSG); 914 919 } else { 915 920 err = enable_counters(); ··· 921 926 if (forks) 922 927 evlist__start_workload(evsel_list); 923 928 924 - if (stat_config.initial_delay > 0) { 925 - usleep(stat_config.initial_delay * USEC_PER_MSEC); 929 + if (target.initial_delay > 0) { 930 + usleep(target.initial_delay * USEC_PER_MSEC); 926 931 err = enable_counters(); 927 932 if (err) 928 933 return -1; ··· 1243 1248 "aggregate counts per thread", AGGR_THREAD), 1244 1249 OPT_SET_UINT(0, "per-node", &stat_config.aggr_mode, 1245 1250 "aggregate counts per numa node", AGGR_NODE), 1246 - OPT_INTEGER('D', "delay", &stat_config.initial_delay, 1251 + OPT_INTEGER('D', "delay", &target.initial_delay, 1247 1252 "ms to wait before starting measurement after program start (-1: start with events disabled)"), 1248 1253 OPT_CALLBACK_NOOPT(0, "metric-only", &stat_config.metric_only, NULL, 1249 1254 "Only print computed metrics. No raw values", enable_metric_only),
+13 -16
tools/perf/tests/shell/lib/perf_json_output_lint.py
··· 40 40 return isfloat(num) or num == '<not counted>' or num == '<not supported>' 41 41 42 42 def check_json_output(expected_items): 43 - if expected_items != -1: 44 - for line in Lines: 45 - if 'failed' not in line: 46 - count = 0 47 - count = line.count(',') 48 - if count != expected_items and count >= 1 and count <= 3 and 'metric-value' in line: 49 - # Events that generate >1 metric may have isolated metric 50 - # values and possibly other prefixes like interval, core and 51 - # aggregate-number. 52 - continue 53 - if count != expected_items: 54 - raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}' 55 - f' in \'{line}\'') 56 43 checks = { 57 44 'aggregate-number': lambda x: isfloat(x), 58 45 'core': lambda x: True, ··· 60 73 } 61 74 input = '[\n' + ','.join(Lines) + '\n]' 62 75 for item in json.loads(input): 76 + if expected_items != -1: 77 + count = len(item) 78 + if count != expected_items and count >= 1 and count <= 4 and 'metric-value' in item: 79 + # Events that generate >1 metric may have isolated metric 80 + # values and possibly other prefixes like interval, core and 81 + # aggregate-number. 82 + pass 83 + elif count != expected_items: 84 + raise RuntimeError(f'wrong number of fields. counted {count} expected {expected_items}' 85 + f' in \'{item}\'') 63 86 for key, value in item.items(): 64 87 if key not in checks: 65 88 raise RuntimeError(f'Unexpected key: key={key} value={value}') ··· 79 82 80 83 try: 81 84 if args.no_args or args.system_wide or args.event: 82 - expected_items = 6 83 - elif args.interval or args.per_thread or args.system_wide_no_aggr: 84 85 expected_items = 7 85 - elif args.per_core or args.per_socket or args.per_node or args.per_die: 86 + elif args.interval or args.per_thread or args.system_wide_no_aggr: 86 87 expected_items = 8 88 + elif args.per_core or args.per_socket or args.per_node or args.per_die: 89 + expected_items = 9 87 90 else: 88 91 # If no option is specified, don't check the number of items. 89 92 expected_items = -1
+12 -11
tools/perf/tests/shell/stat+csv_output.sh
··· 7 7 set -e 8 8 9 9 skip_test=0 10 + csv_sep=@ 10 11 11 12 function commachecker() 12 13 { ··· 35 34 [ "$x" = "Failed" ] && continue 36 35 37 36 # Count the number of commas 38 - x=$(echo $line | tr -d -c ',') 37 + x=$(echo $line | tr -d -c $csv_sep) 39 38 cnt="${#x}" 40 39 # echo $line $cnt 41 40 [[ ! "$cnt" =~ $exp ]] && { ··· 55 54 check_no_args() 56 55 { 57 56 echo -n "Checking CSV output: no args " 58 - perf stat -x, true 2>&1 | commachecker --no-args 57 + perf stat -x$csv_sep true 2>&1 | commachecker --no-args 59 58 echo "[Success]" 60 59 } 61 60 ··· 67 66 echo "[Skip] paranoid and not root" 68 67 return 69 68 fi 70 - perf stat -x, -a true 2>&1 | commachecker --system-wide 69 + perf stat -x$csv_sep -a true 2>&1 | commachecker --system-wide 71 70 echo "[Success]" 72 71 } 73 72 ··· 80 79 return 81 80 fi 82 81 echo -n "Checking CSV output: system wide no aggregation " 83 - perf stat -x, -A -a --no-merge true 2>&1 | commachecker --system-wide-no-aggr 82 + perf stat -x$csv_sep -A -a --no-merge true 2>&1 | commachecker --system-wide-no-aggr 84 83 echo "[Success]" 85 84 } 86 85 87 86 check_interval() 88 87 { 89 88 echo -n "Checking CSV output: interval " 90 - perf stat -x, -I 1000 true 2>&1 | commachecker --interval 89 + perf stat -x$csv_sep -I 1000 true 2>&1 | commachecker --interval 91 90 echo "[Success]" 92 91 } 93 92 ··· 95 94 check_event() 96 95 { 97 96 echo -n "Checking CSV output: event " 98 - perf stat -x, -e cpu-clock true 2>&1 | commachecker --event 97 + perf stat -x$csv_sep -e cpu-clock true 2>&1 | commachecker --event 99 98 echo "[Success]" 100 99 } 101 100 ··· 107 106 echo "[Skip] paranoid and not root" 108 107 return 109 108 fi 110 - perf stat -x, --per-core -a true 2>&1 | commachecker --per-core 109 + perf stat -x$csv_sep --per-core -a true 2>&1 | commachecker --per-core 111 110 echo "[Success]" 112 111 } 113 112 ··· 119 118 echo "[Skip] paranoid and not root" 120 119 return 121 120 fi 122 - perf stat -x, --per-thread -a true 2>&1 | commachecker --per-thread 121 + perf stat -x$csv_sep --per-thread -a true 2>&1 | commachecker --per-thread 123 122 echo "[Success]" 124 123 } 125 124 ··· 131 130 echo "[Skip] paranoid and not root" 132 131 return 133 132 fi 134 - perf stat -x, --per-die -a true 2>&1 | commachecker --per-die 133 + perf stat -x$csv_sep --per-die -a true 2>&1 | commachecker --per-die 135 134 echo "[Success]" 136 135 } 137 136 ··· 143 142 echo "[Skip] paranoid and not root" 144 143 return 145 144 fi 146 - perf stat -x, --per-node -a true 2>&1 | commachecker --per-node 145 + perf stat -x$csv_sep --per-node -a true 2>&1 | commachecker --per-node 147 146 echo "[Success]" 148 147 } 149 148 ··· 155 154 echo "[Skip] paranoid and not root" 156 155 return 157 156 fi 158 - perf stat -x, --per-socket -a true 2>&1 | commachecker --per-socket 157 + perf stat -x$csv_sep --per-socket -a true 2>&1 | commachecker --per-socket 159 158 echo "[Success]" 160 159 } 161 160
+1 -1
tools/perf/util/bpf_skel/off_cpu.bpf.c
··· 277 277 else 278 278 prev_state = get_task_state(prev); 279 279 280 - return off_cpu_stat(ctx, prev, next, prev_state); 280 + return off_cpu_stat(ctx, prev, next, prev_state & 0xff); 281 281 } 282 282 283 283 char LICENSE[] SEC("license") = "Dual BSD/GPL";
+1 -5
tools/perf/util/stat.c
··· 842 842 if (evsel__is_group_leader(evsel)) { 843 843 attr->disabled = 1; 844 844 845 - /* 846 - * In case of initial_delay we enable tracee 847 - * events manually. 848 - */ 849 - if (target__none(target) && !config->initial_delay) 845 + if (target__enable_on_exec(target)) 850 846 attr->enable_on_exec = 1; 851 847 } 852 848
-1
tools/perf/util/stat.h
··· 166 166 FILE *output; 167 167 unsigned int interval; 168 168 unsigned int timeout; 169 - int initial_delay; 170 169 unsigned int unit_width; 171 170 unsigned int metric_only_len; 172 171 int times;
+12
tools/perf/util/target.h
··· 18 18 bool per_thread; 19 19 bool use_bpf; 20 20 bool hybrid; 21 + int initial_delay; 21 22 const char *attr_map; 22 23 }; 23 24 ··· 71 70 static inline bool target__none(struct target *target) 72 71 { 73 72 return !target__has_task(target) && !target__has_cpu(target); 73 + } 74 + 75 + static inline bool target__enable_on_exec(struct target *target) 76 + { 77 + /* 78 + * Normally enable_on_exec should be set if: 79 + * 1) The tracee process is forked (not attaching to existed task or cpu). 80 + * 2) And initial_delay is not configured. 81 + * Otherwise, we enable tracee events manually. 82 + */ 83 + return target__none(target) && !target->initial_delay; 74 84 } 75 85 76 86 static inline bool target__has_per_thread(struct target *target)