Skip to content

Commit 4062549

Browse files
committed
Merge tag 'perf-tools-for-v5.14-2021-07-01' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tool updates from Arnaldo Carvalho de Melo: "Tools: - Add cgroup support for 'perf top' (-G). - Add support for KVM MSRs in 'perf kvm stat' - Support probes on init functions in 'perf probe', to support the bootconfig format. - Improve error reporting in 'perf probe'. - No need to synthesize BUILD_ID records in 'perf inject' if the MMAP2 records have build ids already. - Allow toggling source code ('s' hotkey) in 'perf annotate' in all lines. - Add itrace options support to 'perf annotate'. - Support to custom DSO filters for 'perf script'. Hardware enablement: - Support the HYBRID_TOPOLOGY and HYBRID_CPU_PMU_CAPS features in the perf.data file header. - Support PMU prefix for mem-load and mem-store events, to support hybrid (BIG little) CPUs such as Intel's Alderlake. - Support hybrid CPUs in 'perf mem' and 'perf c2c'. Hardware tracing: - Intel PT now supports tracing KVM guests. - Timestamp improvements for ARM's Coresight. Build: - Add 'make -C tools/perf build-test' entries for libopencsd/CORESIGHT=1 and libbpf/LIBBPF_DYNAMIC=1. - Use bison's --file-prefix-map option to avoid storing full paths when using O= in the perf build. Tests: - Improve the 'perf test' entries for libpfm4 and BPF counters. Misc: - Sync msr-index.h, mount.h, kvm headers with the kernel originals. - Add vendor events and metrics for Intel's Icelake Server & Client" * tag 'perf-tools-for-v5.14-2021-07-01' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (123 commits) perf session: Add missing evlist__delete when deleting a session perf annotate: Allow 's' on source code lines perf dlfilter: Add object_code() to perf_dlfilter_fns perf dlfilter: Add attr() to perf_dlfilter_fns perf dlfilter: Add srcline() to perf_dlfilter_fns perf dlfilter: Add insn() to perf_dlfilter_fns perf dlfilter: Add resolve_address() to perf_dlfilter_fns perf build: Install perf_dlfilter.h perf script: Add option to pass arguments to dlfilters perf script: Add option to list dlfilters perf script: Add dlfilter__filter_event_early() perf script: Add API for filtering via dynamically loaded shared object perf llvm: Return -ENOMEM when asprintf() fails perf cs-etm: Delay decode of non-timeless data until cs_etm__flush_events() tools headers UAPI: Synch KVM's svm.h header with the kernel tools kvm headers arm64: Update KVM headers from the kernel sources tools headers UAPI: Sync linux/kvm.h with the kernel sources tools headers cpufeatures: Sync with the kernel sources tools include UAPI: Update linux/mount.h copy tools arch x86: Sync the msr-index.h copy with the kernel sources ...
2 parents 71bd934 + cf96b8e commit 4062549

File tree

120 files changed

+14120
-2419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+14120
-2419
lines changed

tools/arch/arm64/include/uapi/asm/kvm.h

+11
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ struct kvm_vcpu_events {
184184
__u32 reserved[12];
185185
};
186186

187+
struct kvm_arm_copy_mte_tags {
188+
__u64 guest_ipa;
189+
__u64 length;
190+
void __user *addr;
191+
__u64 flags;
192+
__u64 reserved[2];
193+
};
194+
195+
#define KVM_ARM_TAGS_TO_GUEST 0
196+
#define KVM_ARM_TAGS_FROM_GUEST 1
197+
187198
/* If you need to interpret the index values, here is the key: */
188199
#define KVM_REG_ARM_COPROC_MASK 0x000000000FFF0000
189200
#define KVM_REG_ARM_COPROC_SHIFT 16

tools/arch/x86/include/asm/cpufeatures.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
#define X86_FEATURE_EXTD_APICID ( 3*32+26) /* Extended APICID (8 bits) */
109109
#define X86_FEATURE_AMD_DCM ( 3*32+27) /* AMD multi-node processor */
110110
#define X86_FEATURE_APERFMPERF ( 3*32+28) /* P-State hardware coordination feedback capability (APERF/MPERF MSRs) */
111-
/* free ( 3*32+29) */
111+
#define X86_FEATURE_RAPL ( 3*32+29) /* AMD/Hygon RAPL interface */
112112
#define X86_FEATURE_NONSTOP_TSC_S3 ( 3*32+30) /* TSC doesn't stop in S3 state */
113113
#define X86_FEATURE_TSC_KNOWN_FREQ ( 3*32+31) /* TSC has known frequency */
114114

@@ -378,6 +378,7 @@
378378
#define X86_FEATURE_AVX512_VP2INTERSECT (18*32+ 8) /* AVX-512 Intersect for D/Q */
379379
#define X86_FEATURE_SRBDS_CTRL (18*32+ 9) /* "" SRBDS mitigation MSR available */
380380
#define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */
381+
#define X86_FEATURE_RTM_ALWAYS_ABORT (18*32+11) /* "" RTM transaction always aborts */
381382
#define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */
382383
#define X86_FEATURE_SERIALIZE (18*32+14) /* SERIALIZE instruction */
383384
#define X86_FEATURE_HYBRID_CPU (18*32+15) /* "" This part has CPUs of more than one type */

tools/arch/x86/include/asm/msr-index.h

+4
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,10 @@
772772

773773
#define MSR_TFA_RTM_FORCE_ABORT_BIT 0
774774
#define MSR_TFA_RTM_FORCE_ABORT BIT_ULL(MSR_TFA_RTM_FORCE_ABORT_BIT)
775+
#define MSR_TFA_TSX_CPUID_CLEAR_BIT 1
776+
#define MSR_TFA_TSX_CPUID_CLEAR BIT_ULL(MSR_TFA_TSX_CPUID_CLEAR_BIT)
777+
#define MSR_TFA_SDV_ENABLE_RTM_BIT 2
778+
#define MSR_TFA_SDV_ENABLE_RTM BIT_ULL(MSR_TFA_SDV_ENABLE_RTM_BIT)
775779

776780
/* P4/Xeon+ specific */
777781
#define MSR_IA32_MCG_EAX 0x00000180

tools/arch/x86/include/uapi/asm/kvm.h

+13
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ struct kvm_sregs {
159159
__u64 interrupt_bitmap[(KVM_NR_INTERRUPTS + 63) / 64];
160160
};
161161

162+
struct kvm_sregs2 {
163+
/* out (KVM_GET_SREGS2) / in (KVM_SET_SREGS2) */
164+
struct kvm_segment cs, ds, es, fs, gs, ss;
165+
struct kvm_segment tr, ldt;
166+
struct kvm_dtable gdt, idt;
167+
__u64 cr0, cr2, cr3, cr4, cr8;
168+
__u64 efer;
169+
__u64 apic_base;
170+
__u64 flags;
171+
__u64 pdptrs[4];
172+
};
173+
#define KVM_SREGS2_FLAGS_PDPTRS_VALID 1
174+
162175
/* for KVM_GET_FPU and KVM_SET_FPU */
163176
struct kvm_fpu {
164177
__u8 fpr[8][16];

tools/arch/x86/include/uapi/asm/svm.h

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@
110110
#define SVM_VMGEXIT_GET_AP_JUMP_TABLE 1
111111
#define SVM_VMGEXIT_UNSUPPORTED_EVENT 0x8000ffff
112112

113+
/* Exit code reserved for hypervisor/software use */
114+
#define SVM_EXIT_SW 0xf0000000
115+
113116
#define SVM_EXIT_ERR -1
114117

115118
#define SVM_EXIT_REASONS \

tools/include/linux/bitmap.h

+11
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
1818
int __bitmap_equal(const unsigned long *bitmap1,
1919
const unsigned long *bitmap2, unsigned int bits);
2020
void bitmap_clear(unsigned long *map, unsigned int start, int len);
21+
int __bitmap_intersects(const unsigned long *bitmap1,
22+
const unsigned long *bitmap2, unsigned int bits);
2123

2224
#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) & (BITS_PER_LONG - 1)))
2325
#define BITMAP_LAST_WORD_MASK(nbits) (~0UL >> (-(nbits) & (BITS_PER_LONG - 1)))
@@ -170,4 +172,13 @@ static inline int bitmap_equal(const unsigned long *src1,
170172
return __bitmap_equal(src1, src2, nbits);
171173
}
172174

175+
static inline int bitmap_intersects(const unsigned long *src1,
176+
const unsigned long *src2, unsigned int nbits)
177+
{
178+
if (small_const_nbits(nbits))
179+
return ((*src1 & *src2) & BITMAP_LAST_WORD_MASK(nbits)) != 0;
180+
else
181+
return __bitmap_intersects(src1, src2, nbits);
182+
}
183+
173184
#endif /* _PERF_BITOPS_H */

tools/include/uapi/linux/kvm.h

+105
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ struct kvm_xen_exit {
280280
/* Encounter unexpected vm-exit reason */
281281
#define KVM_INTERNAL_ERROR_UNEXPECTED_EXIT_REASON 4
282282

283+
/* Flags that describe what fields in emulation_failure hold valid data. */
284+
#define KVM_INTERNAL_ERROR_EMULATION_FLAG_INSTRUCTION_BYTES (1ULL << 0)
285+
283286
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
284287
struct kvm_run {
285288
/* in */
@@ -383,6 +386,25 @@ struct kvm_run {
383386
__u32 ndata;
384387
__u64 data[16];
385388
} internal;
389+
/*
390+
* KVM_INTERNAL_ERROR_EMULATION
391+
*
392+
* "struct emulation_failure" is an overlay of "struct internal"
393+
* that is used for the KVM_INTERNAL_ERROR_EMULATION sub-type of
394+
* KVM_EXIT_INTERNAL_ERROR. Note, unlike other internal error
395+
* sub-types, this struct is ABI! It also needs to be backwards
396+
* compatible with "struct internal". Take special care that
397+
* "ndata" is correct, that new fields are enumerated in "flags",
398+
* and that each flag enumerates fields that are 64-bit aligned
399+
* and sized (so that ndata+internal.data[] is valid/accurate).
400+
*/
401+
struct {
402+
__u32 suberror;
403+
__u32 ndata;
404+
__u64 flags;
405+
__u8 insn_size;
406+
__u8 insn_bytes[15];
407+
} emulation_failure;
386408
/* KVM_EXIT_OSI */
387409
struct {
388410
__u64 gprs[32];
@@ -1083,6 +1105,13 @@ struct kvm_ppc_resize_hpt {
10831105
#define KVM_CAP_SGX_ATTRIBUTE 196
10841106
#define KVM_CAP_VM_COPY_ENC_CONTEXT_FROM 197
10851107
#define KVM_CAP_PTP_KVM 198
1108+
#define KVM_CAP_HYPERV_ENFORCE_CPUID 199
1109+
#define KVM_CAP_SREGS2 200
1110+
#define KVM_CAP_EXIT_HYPERCALL 201
1111+
#define KVM_CAP_PPC_RPT_INVALIDATE 202
1112+
#define KVM_CAP_BINARY_STATS_FD 203
1113+
#define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204
1114+
#define KVM_CAP_ARM_MTE 205
10861115

10871116
#ifdef KVM_CAP_IRQ_ROUTING
10881117

@@ -1428,6 +1457,7 @@ struct kvm_s390_ucas_mapping {
14281457
/* Available with KVM_CAP_PMU_EVENT_FILTER */
14291458
#define KVM_SET_PMU_EVENT_FILTER _IOW(KVMIO, 0xb2, struct kvm_pmu_event_filter)
14301459
#define KVM_PPC_SVM_OFF _IO(KVMIO, 0xb3)
1460+
#define KVM_ARM_MTE_COPY_TAGS _IOR(KVMIO, 0xb4, struct kvm_arm_copy_mte_tags)
14311461

14321462
/* ioctl for vm fd */
14331463
#define KVM_CREATE_DEVICE _IOWR(KVMIO, 0xe0, struct kvm_create_device)
@@ -1621,6 +1651,9 @@ struct kvm_xen_hvm_attr {
16211651
#define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
16221652
#define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr)
16231653

1654+
#define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2)
1655+
#define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2)
1656+
16241657
struct kvm_xen_vcpu_attr {
16251658
__u16 type;
16261659
__u16 pad[3];
@@ -1899,4 +1932,76 @@ struct kvm_dirty_gfn {
18991932
#define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
19001933
#define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
19011934

1935+
/**
1936+
* struct kvm_stats_header - Header of per vm/vcpu binary statistics data.
1937+
* @flags: Some extra information for header, always 0 for now.
1938+
* @name_size: The size in bytes of the memory which contains statistics
1939+
* name string including trailing '\0'. The memory is allocated
1940+
* at the send of statistics descriptor.
1941+
* @num_desc: The number of statistics the vm or vcpu has.
1942+
* @id_offset: The offset of the vm/vcpu stats' id string in the file pointed
1943+
* by vm/vcpu stats fd.
1944+
* @desc_offset: The offset of the vm/vcpu stats' descriptor block in the file
1945+
* pointd by vm/vcpu stats fd.
1946+
* @data_offset: The offset of the vm/vcpu stats' data block in the file
1947+
* pointed by vm/vcpu stats fd.
1948+
*
1949+
* This is the header userspace needs to read from stats fd before any other
1950+
* readings. It is used by userspace to discover all the information about the
1951+
* vm/vcpu's binary statistics.
1952+
* Userspace reads this header from the start of the vm/vcpu's stats fd.
1953+
*/
1954+
struct kvm_stats_header {
1955+
__u32 flags;
1956+
__u32 name_size;
1957+
__u32 num_desc;
1958+
__u32 id_offset;
1959+
__u32 desc_offset;
1960+
__u32 data_offset;
1961+
};
1962+
1963+
#define KVM_STATS_TYPE_SHIFT 0
1964+
#define KVM_STATS_TYPE_MASK (0xF << KVM_STATS_TYPE_SHIFT)
1965+
#define KVM_STATS_TYPE_CUMULATIVE (0x0 << KVM_STATS_TYPE_SHIFT)
1966+
#define KVM_STATS_TYPE_INSTANT (0x1 << KVM_STATS_TYPE_SHIFT)
1967+
#define KVM_STATS_TYPE_PEAK (0x2 << KVM_STATS_TYPE_SHIFT)
1968+
#define KVM_STATS_TYPE_MAX KVM_STATS_TYPE_PEAK
1969+
1970+
#define KVM_STATS_UNIT_SHIFT 4
1971+
#define KVM_STATS_UNIT_MASK (0xF << KVM_STATS_UNIT_SHIFT)
1972+
#define KVM_STATS_UNIT_NONE (0x0 << KVM_STATS_UNIT_SHIFT)
1973+
#define KVM_STATS_UNIT_BYTES (0x1 << KVM_STATS_UNIT_SHIFT)
1974+
#define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT)
1975+
#define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT)
1976+
#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES
1977+
1978+
#define KVM_STATS_BASE_SHIFT 8
1979+
#define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT)
1980+
#define KVM_STATS_BASE_POW10 (0x0 << KVM_STATS_BASE_SHIFT)
1981+
#define KVM_STATS_BASE_POW2 (0x1 << KVM_STATS_BASE_SHIFT)
1982+
#define KVM_STATS_BASE_MAX KVM_STATS_BASE_POW2
1983+
1984+
/**
1985+
* struct kvm_stats_desc - Descriptor of a KVM statistics.
1986+
* @flags: Annotations of the stats, like type, unit, etc.
1987+
* @exponent: Used together with @flags to determine the unit.
1988+
* @size: The number of data items for this stats.
1989+
* Every data item is of type __u64.
1990+
* @offset: The offset of the stats to the start of stat structure in
1991+
* struture kvm or kvm_vcpu.
1992+
* @unused: Unused field for future usage. Always 0 for now.
1993+
* @name: The name string for the stats. Its size is indicated by the
1994+
* &kvm_stats_header->name_size.
1995+
*/
1996+
struct kvm_stats_desc {
1997+
__u32 flags;
1998+
__s16 exponent;
1999+
__u16 size;
2000+
__u32 offset;
2001+
__u32 unused;
2002+
char name[];
2003+
};
2004+
2005+
#define KVM_GET_STATS_FD _IO(KVMIO, 0xce)
2006+
19022007
#endif /* __LINUX_KVM_H */

tools/include/uapi/linux/mount.h

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ enum fsconfig_command {
120120
#define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
121121
#define MOUNT_ATTR_NODIRATIME 0x00000080 /* Do not update directory access times */
122122
#define MOUNT_ATTR_IDMAP 0x00100000 /* Idmap mount to @userns_fd in struct mount_attr. */
123+
#define MOUNT_ATTR_NOSYMFOLLOW 0x00200000 /* Do not follow symlinks */
123124

124125
/*
125126
* mount_setattr()

tools/lib/bitmap.c

+14
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,17 @@ int __bitmap_equal(const unsigned long *bitmap1,
8686

8787
return 1;
8888
}
89+
90+
int __bitmap_intersects(const unsigned long *bitmap1,
91+
const unsigned long *bitmap2, unsigned int bits)
92+
{
93+
unsigned int k, lim = bits/BITS_PER_LONG;
94+
for (k = 0; k < lim; ++k)
95+
if (bitmap1[k] & bitmap2[k])
96+
return 1;
97+
98+
if (bits % BITS_PER_LONG)
99+
if ((bitmap1[k] & bitmap2[k]) & BITMAP_LAST_WORD_MASK(bits))
100+
return 1;
101+
return 0;
102+
}

tools/perf/Documentation/itrace.txt

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
L synthesize last branch entries on existing event records
2121
s skip initial number of events
2222
q quicker (less detailed) decoding
23+
Z prefer to ignore timestamps (so-called "timeless" decoding)
2324

2425
The default is all events i.e. the same as --itrace=ibxwpe,
2526
except for perf script where it is --itrace=ce

tools/perf/Documentation/perf-annotate.txt

+7
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ OPTIONS
5858
--ignore-vmlinux::
5959
Ignore vmlinux files.
6060

61+
--itrace::
62+
Options for decoding instruction tracing data. The options are:
63+
64+
include::itrace.txt[]
65+
66+
To disable decoding entirely, use --no-itrace.
67+
6168
-m::
6269
--modules::
6370
Load module symbols. WARNING: use only with -k and LIVE kernel.

0 commit comments

Comments
 (0)