Skip to content

Commit 8b98436

Browse files
committed
Merge tag 'perf-tools-fixes-for-v5.16-2021-11-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
Pull perf tools fixes from Arnaldo Carvalho de Melo: - Fix the 'local_weight', 'weight' (memory access latency), 'local_ins_lat', 'ins_lat' (instruction latency) and 'pstage_cyc' (pipeline stage cycles) sort key sample aggregation. - Fix 'perf test' entry for watchpoints on s/390. - Fix branch_stack entry endianness check in the 'perf test' sample parsing test. - Fix ARM SPE handling on 'perf inject'. - Fix memory leaks detected with ASan. - Fix build on arm64 related to reallocarray() availability. - Sync copies of kernel headers: cpufeatures, kvm, MIPS syscalltable (futex_waitv). * tag 'perf-tools-fixes-for-v5.16-2021-11-19' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: perf evsel: Fix memory leaks relating to unit perf report: Fix memory leaks around perf_tip() perf hist: Fix memory leak of a perf_hpp_fmt tools headers UAPI: Sync MIPS syscall table file changed by new futex_waitv syscall tools build: Fix removal of feature-sync-compare-and-swap feature detection perf inject: Fix ARM SPE handling perf bench: Fix two memory leaks detected with ASan perf test sample-parsing: Fix branch_stack entry endianness check tools headers UAPI: Sync x86's asm/kvm.h with the kernel sources perf sort: Fix the 'p_stage_cyc' sort key behavior perf sort: Fix the 'ins_lat' sort key behavior perf sort: Fix the 'weight' sort key behavior perf tools: Set COMPAT_NEED_REALLOCARRAY for CONFIG_AUXTRACE=1 perf tests wp: Remove unused functions on s390 tools headers UAPI: Sync linux/kvm.h with the kernel sources tools headers cpufeatures: Sync with the kernel sources
2 parents 9539ba4 + b194c9c commit 8b98436

File tree

22 files changed

+136
-109
lines changed

22 files changed

+136
-109
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
#define X86_FEATURE_XSAVEC (10*32+ 1) /* XSAVEC instruction */
278278
#define X86_FEATURE_XGETBV1 (10*32+ 2) /* XGETBV with ECX = 1 instruction */
279279
#define X86_FEATURE_XSAVES (10*32+ 3) /* XSAVES/XRSTORS instructions */
280+
#define X86_FEATURE_XFD (10*32+ 4) /* "" eXtended Feature Disabling */
280281

281282
/*
282283
* Extended auxiliary flags: Linux defined - for features scattered in various
@@ -298,6 +299,7 @@
298299
/* Intel-defined CPU features, CPUID level 0x00000007:1 (EAX), word 12 */
299300
#define X86_FEATURE_AVX_VNNI (12*32+ 4) /* AVX VNNI instructions */
300301
#define X86_FEATURE_AVX512_BF16 (12*32+ 5) /* AVX512 BFLOAT16 instructions */
302+
#define X86_FEATURE_AMX_TILE (18*32+24) /* AMX tile Support */
301303

302304
/* AMD-defined CPU features, CPUID level 0x80000008 (EBX), word 13 */
303305
#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,8 @@ struct kvm_pmu_event_filter {
504504
#define KVM_PMU_EVENT_ALLOW 0
505505
#define KVM_PMU_EVENT_DENY 1
506506

507+
/* for KVM_{GET,SET,HAS}_DEVICE_ATTR */
508+
#define KVM_VCPU_TSC_CTRL 0 /* control group for the timestamp counter (TSC) */
509+
#define KVM_VCPU_TSC_OFFSET 0 /* attribute for the TSC offset */
510+
507511
#endif /* _ASM_X86_KVM_H */

tools/build/feature/test-all.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ int main(int argc, char *argv[])
200200
main_test_timerfd();
201201
main_test_stackprotector_all();
202202
main_test_libdw_dwarf_unwind();
203-
main_test_sync_compare_and_swap(argc, argv);
204203
main_test_zlib();
205204
main_test_pthread_attr_setaffinity_np();
206205
main_test_pthread_barrier();

tools/include/uapi/linux/kvm.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ struct kvm_xen_exit {
269269
#define KVM_EXIT_AP_RESET_HOLD 32
270270
#define KVM_EXIT_X86_BUS_LOCK 33
271271
#define KVM_EXIT_XEN 34
272+
#define KVM_EXIT_RISCV_SBI 35
272273

273274
/* For KVM_EXIT_INTERNAL_ERROR */
274275
/* Emulate instruction failed. */
@@ -397,13 +398,23 @@ struct kvm_run {
397398
* "ndata" is correct, that new fields are enumerated in "flags",
398399
* and that each flag enumerates fields that are 64-bit aligned
399400
* and sized (so that ndata+internal.data[] is valid/accurate).
401+
*
402+
* Space beyond the defined fields may be used to store arbitrary
403+
* debug information relating to the emulation failure. It is
404+
* accounted for in "ndata" but the format is unspecified and is
405+
* not represented in "flags". Any such information is *not* ABI!
400406
*/
401407
struct {
402408
__u32 suberror;
403409
__u32 ndata;
404410
__u64 flags;
405-
__u8 insn_size;
406-
__u8 insn_bytes[15];
411+
union {
412+
struct {
413+
__u8 insn_size;
414+
__u8 insn_bytes[15];
415+
};
416+
};
417+
/* Arbitrary debug data may follow. */
407418
} emulation_failure;
408419
/* KVM_EXIT_OSI */
409420
struct {
@@ -469,6 +480,13 @@ struct kvm_run {
469480
} msr;
470481
/* KVM_EXIT_XEN */
471482
struct kvm_xen_exit xen;
483+
/* KVM_EXIT_RISCV_SBI */
484+
struct {
485+
unsigned long extension_id;
486+
unsigned long function_id;
487+
unsigned long args[6];
488+
unsigned long ret[2];
489+
} riscv_sbi;
472490
/* Fix the size of the union. */
473491
char padding[256];
474492
};
@@ -1112,6 +1130,7 @@ struct kvm_ppc_resize_hpt {
11121130
#define KVM_CAP_BINARY_STATS_FD 203
11131131
#define KVM_CAP_EXIT_ON_EMULATION_FAILURE 204
11141132
#define KVM_CAP_ARM_MTE 205
1133+
#define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206
11151134

11161135
#ifdef KVM_CAP_IRQ_ROUTING
11171136

@@ -1223,11 +1242,16 @@ struct kvm_irqfd {
12231242

12241243
/* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */
12251244
#define KVM_CLOCK_TSC_STABLE 2
1245+
#define KVM_CLOCK_REALTIME (1 << 2)
1246+
#define KVM_CLOCK_HOST_TSC (1 << 3)
12261247

12271248
struct kvm_clock_data {
12281249
__u64 clock;
12291250
__u32 flags;
1230-
__u32 pad[9];
1251+
__u32 pad0;
1252+
__u64 realtime;
1253+
__u64 host_tsc;
1254+
__u32 pad[4];
12311255
};
12321256

12331257
/* For KVM_CAP_SW_TLB */

tools/perf/Makefile.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,9 @@ ifndef NO_AUXTRACE
10101010
ifndef NO_AUXTRACE
10111011
$(call detected,CONFIG_AUXTRACE)
10121012
CFLAGS += -DHAVE_AUXTRACE_SUPPORT
1013+
ifeq ($(feature-reallocarray), 0)
1014+
CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
1015+
endif
10131016
endif
10141017
endif
10151018

tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,3 +363,4 @@
363363
446 n64 landlock_restrict_self sys_landlock_restrict_self
364364
# 447 reserved for memfd_secret
365365
448 n64 process_mrelease sys_process_mrelease
366+
449 n64 futex_waitv sys_futex_waitv

tools/perf/bench/sched-messaging.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ static unsigned int group(pthread_t *pth,
223223
snd_ctx->out_fds[i] = fds[1];
224224
if (!thread_mode)
225225
close(fds[0]);
226+
227+
free(ctx);
226228
}
227229

228230
/* Now we have all the fds, fork the senders */
@@ -239,6 +241,8 @@ static unsigned int group(pthread_t *pth,
239241
for (i = 0; i < num_fds; i++)
240242
close(snd_ctx->out_fds[i]);
241243

244+
free(snd_ctx);
245+
242246
/* Return number of children to reap */
243247
return num_fds * 2;
244248
}

tools/perf/builtin-report.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,14 +619,17 @@ static int report__browse_hists(struct report *rep)
619619
int ret;
620620
struct perf_session *session = rep->session;
621621
struct evlist *evlist = session->evlist;
622-
const char *help = perf_tip(system_path(TIPDIR));
622+
char *help = NULL, *path = NULL;
623623

624-
if (help == NULL) {
624+
path = system_path(TIPDIR);
625+
if (perf_tip(&help, path) || help == NULL) {
625626
/* fallback for people who don't install perf ;-) */
626-
help = perf_tip(DOCDIR);
627-
if (help == NULL)
628-
help = "Cannot load tips.txt file, please install perf!";
627+
free(path);
628+
path = system_path(DOCDIR);
629+
if (perf_tip(&help, path) || help == NULL)
630+
help = strdup("Cannot load tips.txt file, please install perf!");
629631
}
632+
free(path);
630633

631634
switch (use_browser) {
632635
case 1:
@@ -651,7 +654,7 @@ static int report__browse_hists(struct report *rep)
651654
ret = evlist__tty_browse_hists(evlist, rep, help);
652655
break;
653656
}
654-
657+
free(help);
655658
return ret;
656659
}
657660

tools/perf/tests/event_update.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ static int test__event_update(struct test_suite *test __maybe_unused, int subtes
8888
struct evsel *evsel;
8989
struct event_name tmp;
9090
struct evlist *evlist = evlist__new_default();
91-
char *unit = strdup("KRAVA");
9291

9392
TEST_ASSERT_VAL("failed to get evlist", evlist);
9493

@@ -99,7 +98,8 @@ static int test__event_update(struct test_suite *test __maybe_unused, int subtes
9998

10099
perf_evlist__id_add(&evlist->core, &evsel->core, 0, 0, 123);
101100

102-
evsel->unit = unit;
101+
free((char *)evsel->unit);
102+
evsel->unit = strdup("KRAVA");
103103

104104
TEST_ASSERT_VAL("failed to synthesize attr update unit",
105105
!perf_event__synthesize_event_update_unit(NULL, evsel, process_event_unit));
@@ -119,7 +119,6 @@ static int test__event_update(struct test_suite *test __maybe_unused, int subtes
119119
TEST_ASSERT_VAL("failed to synthesize attr update cpus",
120120
!perf_event__synthesize_event_update_cpus(&tmp.tool, evsel, process_event_cpus));
121121

122-
free(unit);
123122
evlist__delete(evlist);
124123
return 0;
125124
}

tools/perf/tests/sample-parsing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* These are based on the input value (213) specified
3737
* in branch_stack variable.
3838
*/
39-
#define BS_EXPECTED_BE 0xa00d000000000000
39+
#define BS_EXPECTED_BE 0xa000d00000000000
4040
#define BS_EXPECTED_LE 0xd5000000
4141
#define FLAG(s) s->branch_stack->entries[i].flags
4242

0 commit comments

Comments
 (0)