Skip to content

Commit ccff6d1

Browse files
committed
Merge tag 'perf-tools-fixes-for-v6.5-1-2023-07-18' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Don't group events when computing metrics that require more than the maximum number of simultaneously enabled events on AMD systems. - Fix multi CU handling in 'perf probe', add a 'perf test' entry to regress test it. - Make the 'perf test task_exit' stop generating samples by using the 'dummy' event, all it is testing is if a PERF_RECORD_EXIT is generated at the end of a perf session. This makes this perf test to stop sometimes failing on some systems due to a full ring buffer. - Avoid SEGV if PMU lookup fails for legacy cache terms. - Fix libsubcmd SEGV/use-after-free when commands aren't excluded. - Fix OpenCSD (ARM64's CoreSight hardware tracing) library path resolution when specifying CSLIBS= in the make command line. - Fix broken feature check for libtracefs due to external lib changes, use the provided pkgconfig file instead future proof it. - Sync drm, fcntl, kvm, mount, prctl, socket, vhost, asound, arm64's cputype headers with the kernel sources, in some cases this made the tools become aware of new kernel APIs such as ioctls and the cachestat sysctl. * tag 'perf-tools-fixes-for-v6.5-1-2023-07-18' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: perf test task_exit: No need for a cycles event to check if we get an PERF_RECORD_EXIT tools headers arm64: Sync arm64's cputype.h with the kernel sources tools include UAPI: Sync the sound/asound.h copy with the kernel sources tools include UAPI: Sync linux/vhost.h with the kernel sources perf beauty: Update copy of linux/socket.h with the kernel sources perf parse-events: Avoid SEGV if PMU lookup fails for legacy cache terms libsubcmd: Avoid SEGV/use-after-free when commands aren't excluded tools headers UAPI: Sync linux/prctl.h with the kernel sources perf build: Fix broken feature check for libtracefs due to external lib changes tools include UAPI: Sync linux/mount.h copy with the kernel sources tools headers UAPI: Sync linux/kvm.h with the kernel sources tools headers uapi: Sync linux/fcntl.h with the kernel sources perf vendor events amd: Fix large metrics perf build: Fix library not found error when using CSLIBS tools headers UAPI: Sync files changed by new cachestat syscall with the kernel sources tools headers UAPI: Sync drm/i915_drm.h with the kernel sources perf probe: Read DWARF files from the correct CU perf probe: Add test for regression introduced by switch to die_get_decl_file()
2 parents 4806364 + 2480232 commit ccff6d1

File tree

27 files changed

+381
-23
lines changed

27 files changed

+381
-23
lines changed

tools/arch/arm64/include/asm/cputype.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@
126126
#define APPLE_CPU_PART_M1_FIRESTORM_MAX 0x029
127127
#define APPLE_CPU_PART_M2_BLIZZARD 0x032
128128
#define APPLE_CPU_PART_M2_AVALANCHE 0x033
129+
#define APPLE_CPU_PART_M2_BLIZZARD_PRO 0x034
130+
#define APPLE_CPU_PART_M2_AVALANCHE_PRO 0x035
131+
#define APPLE_CPU_PART_M2_BLIZZARD_MAX 0x038
132+
#define APPLE_CPU_PART_M2_AVALANCHE_MAX 0x039
129133

130134
#define AMPERE_CPU_PART_AMPERE1 0xAC3
131135

@@ -181,6 +185,10 @@
181185
#define MIDR_APPLE_M1_FIRESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_MAX)
182186
#define MIDR_APPLE_M2_BLIZZARD MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD)
183187
#define MIDR_APPLE_M2_AVALANCHE MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE)
188+
#define MIDR_APPLE_M2_BLIZZARD_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_PRO)
189+
#define MIDR_APPLE_M2_AVALANCHE_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_PRO)
190+
#define MIDR_APPLE_M2_BLIZZARD_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX)
191+
#define MIDR_APPLE_M2_AVALANCHE_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX)
184192
#define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1)
185193

186194
/* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */

tools/build/feature/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ $(OUTPUT)test-libtraceevent.bin:
208208
$(BUILD) -ltraceevent
209209

210210
$(OUTPUT)test-libtracefs.bin:
211-
$(BUILD) -ltracefs
211+
$(BUILD) $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null) -ltracefs
212212

213213
$(OUTPUT)test-libcrypto.bin:
214214
$(BUILD) -lcrypto

tools/include/uapi/asm-generic/unistd.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,11 @@ __SYSCALL(__NR_futex_waitv, sys_futex_waitv)
817817
#define __NR_set_mempolicy_home_node 450
818818
__SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node)
819819

820+
#define __NR_cachestat 451
821+
__SYSCALL(__NR_cachestat, sys_cachestat)
822+
820823
#undef __NR_syscalls
821-
#define __NR_syscalls 451
824+
#define __NR_syscalls 452
822825

823826
/*
824827
* 32 bit systems traditionally used different

tools/include/uapi/drm/i915_drm.h

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,16 @@ enum drm_i915_pmu_engine_sample {
280280
#define I915_PMU_ENGINE_SEMA(class, instance) \
281281
__I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA)
282282

283-
#define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x))
283+
/*
284+
* Top 4 bits of every non-engine counter are GT id.
285+
*/
286+
#define __I915_PMU_GT_SHIFT (60)
287+
288+
#define ___I915_PMU_OTHER(gt, x) \
289+
(((__u64)__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) | \
290+
((__u64)(gt) << __I915_PMU_GT_SHIFT))
291+
292+
#define __I915_PMU_OTHER(x) ___I915_PMU_OTHER(0, x)
284293

285294
#define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0)
286295
#define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1)
@@ -290,6 +299,12 @@ enum drm_i915_pmu_engine_sample {
290299

291300
#define I915_PMU_LAST /* Deprecated - do not use */ I915_PMU_RC6_RESIDENCY
292301

302+
#define __I915_PMU_ACTUAL_FREQUENCY(gt) ___I915_PMU_OTHER(gt, 0)
303+
#define __I915_PMU_REQUESTED_FREQUENCY(gt) ___I915_PMU_OTHER(gt, 1)
304+
#define __I915_PMU_INTERRUPTS(gt) ___I915_PMU_OTHER(gt, 2)
305+
#define __I915_PMU_RC6_RESIDENCY(gt) ___I915_PMU_OTHER(gt, 3)
306+
#define __I915_PMU_SOFTWARE_GT_AWAKE_TIME(gt) ___I915_PMU_OTHER(gt, 4)
307+
293308
/* Each region is a minimum of 16k, and there are at most 255 of them.
294309
*/
295310
#define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use
@@ -659,7 +674,8 @@ typedef struct drm_i915_irq_wait {
659674
* If the IOCTL is successful, the returned parameter will be set to one of the
660675
* following values:
661676
* * 0 if HuC firmware load is not complete,
662-
* * 1 if HuC firmware is authenticated and running.
677+
* * 1 if HuC firmware is loaded and fully authenticated,
678+
* * 2 if HuC firmware is loaded and authenticated for clear media only
663679
*/
664680
#define I915_PARAM_HUC_STATUS 42
665681

@@ -771,6 +787,25 @@ typedef struct drm_i915_irq_wait {
771787
*/
772788
#define I915_PARAM_OA_TIMESTAMP_FREQUENCY 57
773789

790+
/*
791+
* Query the status of PXP support in i915.
792+
*
793+
* The query can fail in the following scenarios with the listed error codes:
794+
* -ENODEV = PXP support is not available on the GPU device or in the
795+
* kernel due to missing component drivers or kernel configs.
796+
*
797+
* If the IOCTL is successful, the returned parameter will be set to one of
798+
* the following values:
799+
* 1 = PXP feature is supported and is ready for use.
800+
* 2 = PXP feature is supported but should be ready soon (pending
801+
* initialization of non-i915 system dependencies).
802+
*
803+
* NOTE: When param is supported (positive return values), user space should
804+
* still refer to the GEM PXP context-creation UAPI header specs to be
805+
* aware of possible failure due to system state machine at the time.
806+
*/
807+
#define I915_PARAM_PXP_STATUS 58
808+
774809
/* Must be kept compact -- no holes and well documented */
775810

776811
/**
@@ -2096,6 +2131,21 @@ struct drm_i915_gem_context_param {
20962131
*
20972132
* -ENODEV: feature not available
20982133
* -EPERM: trying to mark a recoverable or not bannable context as protected
2134+
* -ENXIO: A dependency such as a component driver or firmware is not yet
2135+
* loaded so user space may need to attempt again. Depending on the
2136+
* device, this error may be reported if protected context creation is
2137+
* attempted very early after kernel start because the internal timeout
2138+
* waiting for such dependencies is not guaranteed to be larger than
2139+
* required (numbers differ depending on system and kernel config):
2140+
* - ADL/RPL: dependencies may take up to 3 seconds from kernel start
2141+
* while context creation internal timeout is 250 milisecs
2142+
* - MTL: dependencies may take up to 8 seconds from kernel start
2143+
* while context creation internal timeout is 250 milisecs
2144+
* NOTE: such dependencies happen once, so a subsequent call to create a
2145+
* protected context after a prior successful call will not experience
2146+
* such timeouts and will not return -ENXIO (unless the driver is reloaded,
2147+
* or, depending on the device, resumes from a suspended state).
2148+
* -EIO: The firmware did not succeed in creating the protected context.
20992149
*/
21002150
#define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd
21012151
/* Must be kept compact -- no holes and well documented */
@@ -3630,9 +3680,13 @@ struct drm_i915_gem_create_ext {
36303680
*
36313681
* For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see
36323682
* struct drm_i915_gem_create_ext_protected_content.
3683+
*
3684+
* For I915_GEM_CREATE_EXT_SET_PAT usage see
3685+
* struct drm_i915_gem_create_ext_set_pat.
36333686
*/
36343687
#define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0
36353688
#define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1
3689+
#define I915_GEM_CREATE_EXT_SET_PAT 2
36363690
__u64 extensions;
36373691
};
36383692

@@ -3747,6 +3801,43 @@ struct drm_i915_gem_create_ext_protected_content {
37473801
__u32 flags;
37483802
};
37493803

3804+
/**
3805+
* struct drm_i915_gem_create_ext_set_pat - The
3806+
* I915_GEM_CREATE_EXT_SET_PAT extension.
3807+
*
3808+
* If this extension is provided, the specified caching policy (PAT index) is
3809+
* applied to the buffer object.
3810+
*
3811+
* Below is an example on how to create an object with specific caching policy:
3812+
*
3813+
* .. code-block:: C
3814+
*
3815+
* struct drm_i915_gem_create_ext_set_pat set_pat_ext = {
3816+
* .base = { .name = I915_GEM_CREATE_EXT_SET_PAT },
3817+
* .pat_index = 0,
3818+
* };
3819+
* struct drm_i915_gem_create_ext create_ext = {
3820+
* .size = PAGE_SIZE,
3821+
* .extensions = (uintptr_t)&set_pat_ext,
3822+
* };
3823+
*
3824+
* int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext);
3825+
* if (err) ...
3826+
*/
3827+
struct drm_i915_gem_create_ext_set_pat {
3828+
/** @base: Extension link. See struct i915_user_extension. */
3829+
struct i915_user_extension base;
3830+
/**
3831+
* @pat_index: PAT index to be set
3832+
* PAT index is a bit field in Page Table Entry to control caching
3833+
* behaviors for GPU accesses. The definition of PAT index is
3834+
* platform dependent and can be found in hardware specifications,
3835+
*/
3836+
__u32 pat_index;
3837+
/** @rsvd: reserved for future use */
3838+
__u32 rsvd;
3839+
};
3840+
37503841
/* ID of the protected content session managed by i915 when PXP is active */
37513842
#define I915_PROTECTED_CONTENT_DEFAULT_SESSION 0xf
37523843

tools/include/uapi/linux/fcntl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,9 @@
112112

113113
#define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */
114114

115+
/* Flags for name_to_handle_at(2). We reuse AT_ flag space to save bits... */
116+
#define AT_HANDLE_FID AT_REMOVEDIR /* file handle is needed to
117+
compare object identity and may not
118+
be usable to open_by_handle_at(2) */
119+
115120
#endif /* _UAPI_LINUX_FCNTL_H */

tools/include/uapi/linux/kvm.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,8 @@ struct kvm_ppc_resize_hpt {
11901190
#define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225
11911191
#define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226
11921192
#define KVM_CAP_COUNTER_OFFSET 227
1193+
#define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228
1194+
#define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229
11931195

11941196
#ifdef KVM_CAP_IRQ_ROUTING
11951197

@@ -1442,6 +1444,8 @@ enum kvm_device_type {
14421444
#define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE
14431445
KVM_DEV_TYPE_ARM_PV_TIME,
14441446
#define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME
1447+
KVM_DEV_TYPE_RISCV_AIA,
1448+
#define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA
14451449
KVM_DEV_TYPE_MAX,
14461450
};
14471451

@@ -1613,7 +1617,7 @@ struct kvm_s390_ucas_mapping {
16131617
#define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs)
16141618
#define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs)
16151619
/*
1616-
* vcpu version available with KVM_ENABLE_CAP
1620+
* vcpu version available with KVM_CAP_ENABLE_CAP
16171621
* vm version available with KVM_CAP_ENABLE_CAP_VM
16181622
*/
16191623
#define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)

tools/include/uapi/linux/mman.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <asm/mman.h>
66
#include <asm-generic/hugetlb_encode.h>
7+
#include <linux/types.h>
78

89
#define MREMAP_MAYMOVE 1
910
#define MREMAP_FIXED 2
@@ -41,4 +42,17 @@
4142
#define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB
4243
#define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB
4344

45+
struct cachestat_range {
46+
__u64 off;
47+
__u64 len;
48+
};
49+
50+
struct cachestat {
51+
__u64 nr_cache;
52+
__u64 nr_dirty;
53+
__u64 nr_writeback;
54+
__u64 nr_evicted;
55+
__u64 nr_recently_evicted;
56+
};
57+
4458
#endif /* _UAPI_LINUX_MMAN_H */

tools/include/uapi/linux/mount.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
#define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020 /* Follow automounts on to path */
7575
#define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */
7676
#define MOVE_MOUNT_SET_GROUP 0x00000100 /* Set sharing group instead */
77-
#define MOVE_MOUNT__MASK 0x00000177
77+
#define MOVE_MOUNT_BENEATH 0x00000200 /* Mount beneath top mount */
78+
#define MOVE_MOUNT__MASK 0x00000377
7879

7980
/*
8081
* fsopen() flags.

tools/include/uapi/linux/prctl.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,15 @@ struct prctl_mm_map {
294294

295295
#define PR_SET_MEMORY_MERGE 67
296296
#define PR_GET_MEMORY_MERGE 68
297+
298+
#define PR_RISCV_V_SET_CONTROL 69
299+
#define PR_RISCV_V_GET_CONTROL 70
300+
# define PR_RISCV_V_VSTATE_CTRL_DEFAULT 0
301+
# define PR_RISCV_V_VSTATE_CTRL_OFF 1
302+
# define PR_RISCV_V_VSTATE_CTRL_ON 2
303+
# define PR_RISCV_V_VSTATE_CTRL_INHERIT (1 << 4)
304+
# define PR_RISCV_V_VSTATE_CTRL_CUR_MASK 0x3
305+
# define PR_RISCV_V_VSTATE_CTRL_NEXT_MASK 0xc
306+
# define PR_RISCV_V_VSTATE_CTRL_MASK 0x1f
307+
297308
#endif /* _LINUX_PRCTL_H */

tools/include/uapi/linux/vhost.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@
4545
#define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64)
4646
/* Specify an eventfd file descriptor to signal on log write. */
4747
#define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int)
48+
/* By default, a device gets one vhost_worker that its virtqueues share. This
49+
* command allows the owner of the device to create an additional vhost_worker
50+
* for the device. It can later be bound to 1 or more of its virtqueues using
51+
* the VHOST_ATTACH_VRING_WORKER command.
52+
*
53+
* This must be called after VHOST_SET_OWNER and the caller must be the owner
54+
* of the device. The new thread will inherit caller's cgroups and namespaces,
55+
* and will share the caller's memory space. The new thread will also be
56+
* counted against the caller's RLIMIT_NPROC value.
57+
*
58+
* The worker's ID used in other commands will be returned in
59+
* vhost_worker_state.
60+
*/
61+
#define VHOST_NEW_WORKER _IOR(VHOST_VIRTIO, 0x8, struct vhost_worker_state)
62+
/* Free a worker created with VHOST_NEW_WORKER if it's not attached to any
63+
* virtqueue. If userspace is not able to call this for workers its created,
64+
* the kernel will free all the device's workers when the device is closed.
65+
*/
66+
#define VHOST_FREE_WORKER _IOW(VHOST_VIRTIO, 0x9, struct vhost_worker_state)
4867

4968
/* Ring setup. */
5069
/* Set number of descriptors in ring. This parameter can not
@@ -70,6 +89,18 @@
7089
#define VHOST_VRING_BIG_ENDIAN 1
7190
#define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state)
7291
#define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state)
92+
/* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's
93+
* virtqueues.
94+
*
95+
* This will replace the virtqueue's existing worker. If the replaced worker
96+
* is no longer attached to any virtqueues, it can be freed with
97+
* VHOST_FREE_WORKER.
98+
*/
99+
#define VHOST_ATTACH_VRING_WORKER _IOW(VHOST_VIRTIO, 0x15, \
100+
struct vhost_vring_worker)
101+
/* Return the vring worker's ID */
102+
#define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16, \
103+
struct vhost_vring_worker)
73104

74105
/* The following ioctls use eventfd file descriptors to signal and poll
75106
* for events. */

0 commit comments

Comments
 (0)