Skip to content

Commit a8a31fd

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Thomas Gleixner: "A set of perf fixes: kernel: - Unbreak the tracking of auxiliary buffer allocations which got imbalanced causing recource limit failures. - Fix the fallout of splitting of ToPA entries which missed to shift the base entry PA correctly. - Use the correct context to lookup the AUX event when unmapping the associated AUX buffer so the event can be stopped and the buffer reference dropped. tools: - Fix buildiid-cache mode setting in copyfile_mode_ns() when copying /proc/kcore - Fix freeing id arrays in the event list so the correct event is closed. - Sync sched.h anc kvm.h headers with the kernel sources. - Link jvmti against tools/lib/ctype.o to have weak strlcpy(). - Fix multiple memory and file descriptor leaks, found by coverity in perf annotate. - Fix leaks in error handling paths in 'perf c2c', 'perf kmem', found by a static analysis tool" * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: perf/aux: Fix AUX output stopping perf/aux: Fix tracking of auxiliary trace buffer allocation perf/x86/intel/pt: Fix base for single entry topa perf kmem: Fix memory leak in compact_gfp_flags() tools headers UAPI: Sync sched.h with the kernel tools headers kvm: Sync kvm.h headers with the kernel sources tools headers kvm: Sync kvm headers with the kernel sources tools headers kvm: Sync kvm headers with the kernel sources perf c2c: Fix memory leak in build_cl_output() perf tools: Fix mode setting in copyfile_mode_ns() perf annotate: Fix multiple memory and file descriptor leaks perf tools: Fix resource leak of closedir() on the error paths perf evlist: Fix fix for freed id arrays perf jvmti: Link against tools/lib/ctype.h to have weak strlcpy()
2 parents 1e1ac1c + f3a519e commit a8a31fd

File tree

14 files changed

+71
-21
lines changed

14 files changed

+71
-21
lines changed

arch/x86/events/intel/pt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ static struct topa *topa_alloc(int cpu, gfp_t gfp)
627627
* link as the 2nd entry in the table
628628
*/
629629
if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) {
630-
TOPA_ENTRY(&tp->topa, 1)->base = page_to_phys(p);
630+
TOPA_ENTRY(&tp->topa, 1)->base = page_to_phys(p) >> TOPA_SHIFT;
631631
TOPA_ENTRY(&tp->topa, 1)->end = 1;
632632
}
633633

kernel/events/core.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5607,8 +5607,10 @@ static void perf_mmap_close(struct vm_area_struct *vma)
56075607
perf_pmu_output_stop(event);
56085608

56095609
/* now it's safe to free the pages */
5610-
atomic_long_sub(rb->aux_nr_pages, &mmap_user->locked_vm);
5611-
atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);
5610+
if (!rb->aux_mmap_locked)
5611+
atomic_long_sub(rb->aux_nr_pages, &mmap_user->locked_vm);
5612+
else
5613+
atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);
56125614

56135615
/* this has to be the last one */
56145616
rb_free_aux(rb);
@@ -6947,7 +6949,7 @@ static void __perf_event_output_stop(struct perf_event *event, void *data)
69476949
static int __perf_pmu_output_stop(void *info)
69486950
{
69496951
struct perf_event *event = info;
6950-
struct pmu *pmu = event->pmu;
6952+
struct pmu *pmu = event->ctx->pmu;
69516953
struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
69526954
struct remote_output ro = {
69536955
.rb = event->rb,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#define SVM_EXIT_MWAIT 0x08b
7676
#define SVM_EXIT_MWAIT_COND 0x08c
7777
#define SVM_EXIT_XSETBV 0x08d
78+
#define SVM_EXIT_RDPRU 0x08e
7879
#define SVM_EXIT_NPF 0x400
7980
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
8081
#define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
#define EXIT_REASON_PML_FULL 62
8787
#define EXIT_REASON_XSAVES 63
8888
#define EXIT_REASON_XRSTORS 64
89+
#define EXIT_REASON_UMWAIT 67
90+
#define EXIT_REASON_TPAUSE 68
8991

9092
#define VMX_EXIT_REASONS \
9193
{ EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \
@@ -144,7 +146,9 @@
144146
{ EXIT_REASON_RDSEED, "RDSEED" }, \
145147
{ EXIT_REASON_PML_FULL, "PML_FULL" }, \
146148
{ EXIT_REASON_XSAVES, "XSAVES" }, \
147-
{ EXIT_REASON_XRSTORS, "XRSTORS" }
149+
{ EXIT_REASON_XRSTORS, "XRSTORS" }, \
150+
{ EXIT_REASON_UMWAIT, "UMWAIT" }, \
151+
{ EXIT_REASON_TPAUSE, "TPAUSE" }
148152

149153
#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
150154
#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2

tools/include/uapi/linux/kvm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ struct kvm_ppc_resize_hpt {
999999
#define KVM_CAP_ARM_PTRAUTH_GENERIC 172
10001000
#define KVM_CAP_PMU_EVENT_FILTER 173
10011001
#define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
1002+
#define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
10021003

10031004
#ifdef KVM_CAP_IRQ_ROUTING
10041005

@@ -1145,6 +1146,7 @@ struct kvm_dirty_tlb {
11451146
#define KVM_REG_S390 0x5000000000000000ULL
11461147
#define KVM_REG_ARM64 0x6000000000000000ULL
11471148
#define KVM_REG_MIPS 0x7000000000000000ULL
1149+
#define KVM_REG_RISCV 0x8000000000000000ULL
11481150

11491151
#define KVM_REG_SIZE_SHIFT 52
11501152
#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL

tools/include/uapi/linux/sched.h

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,31 @@
3333
#define CLONE_NEWNET 0x40000000 /* New network namespace */
3434
#define CLONE_IO 0x80000000 /* Clone io context */
3535

36-
/*
37-
* Arguments for the clone3 syscall
36+
#ifndef __ASSEMBLY__
37+
/**
38+
* struct clone_args - arguments for the clone3 syscall
39+
* @flags: Flags for the new process as listed above.
40+
* All flags are valid except for CSIGNAL and
41+
* CLONE_DETACHED.
42+
* @pidfd: If CLONE_PIDFD is set, a pidfd will be
43+
* returned in this argument.
44+
* @child_tid: If CLONE_CHILD_SETTID is set, the TID of the
45+
* child process will be returned in the child's
46+
* memory.
47+
* @parent_tid: If CLONE_PARENT_SETTID is set, the TID of
48+
* the child process will be returned in the
49+
* parent's memory.
50+
* @exit_signal: The exit_signal the parent process will be
51+
* sent when the child exits.
52+
* @stack: Specify the location of the stack for the
53+
* child process.
54+
* @stack_size: The size of the stack for the child process.
55+
* @tls: If CLONE_SETTLS is set, the tls descriptor
56+
* is set to tls.
57+
*
58+
* The structure is versioned by size and thus extensible.
59+
* New struct members must go at the end of the struct and
60+
* must be properly 64bit aligned.
3861
*/
3962
struct clone_args {
4063
__aligned_u64 flags;
@@ -46,6 +69,9 @@ struct clone_args {
4669
__aligned_u64 stack_size;
4770
__aligned_u64 tls;
4871
};
72+
#endif
73+
74+
#define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */
4975

5076
/*
5177
* Scheduling policies

tools/perf/builtin-c2c.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
26352635
bool add_sym = false;
26362636
bool add_dso = false;
26372637
bool add_src = false;
2638+
int ret = 0;
26382639

26392640
if (!buf)
26402641
return -ENOMEM;
@@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
26532654
add_dso = true;
26542655
} else if (strcmp(tok, "offset")) {
26552656
pr_err("unrecognized sort token: %s\n", tok);
2656-
return -EINVAL;
2657+
ret = -EINVAL;
2658+
goto err;
26572659
}
26582660
}
26592661

@@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
26762678
add_sym ? "symbol," : "",
26772679
add_dso ? "dso," : "",
26782680
add_src ? "cl_srcline," : "",
2679-
"node") < 0)
2680-
return -ENOMEM;
2681+
"node") < 0) {
2682+
ret = -ENOMEM;
2683+
goto err;
2684+
}
26812685

26822686
c2c.show_src = add_src;
2683-
2687+
err:
26842688
free(buf);
2685-
return 0;
2689+
return ret;
26862690
}
26872691

26882692
static int setup_coalesce(const char *coalesce, bool no_source)

tools/perf/builtin-kmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
691691
new = realloc(new_flags, len + strlen(cpt) + 2);
692692
if (new == NULL) {
693693
free(new_flags);
694+
free(orig_flags);
694695
return NULL;
695696
}
696697

tools/perf/jvmti/Build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ jvmti-y += libjvmti.o
22
jvmti-y += jvmti_agent.o
33

44
# For strlcpy
5-
jvmti-y += libstring.o
5+
jvmti-y += libstring.o libctype.o
66

77
CFLAGS_jvmti = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux
88
CFLAGS_REMOVE_jvmti = -Wmissing-declarations
@@ -15,3 +15,7 @@ CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PE
1515
$(OUTPUT)jvmti/libstring.o: ../lib/string.c FORCE
1616
$(call rule_mkdir)
1717
$(call if_changed_dep,cc_o_c)
18+
19+
$(OUTPUT)jvmti/libctype.o: ../lib/ctype.c FORCE
20+
$(call rule_mkdir)
21+
$(call if_changed_dep,cc_o_c)

tools/perf/util/annotate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
17581758
info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
17591759
dso->bpf_prog.id);
17601760
if (!info_node) {
1761-
return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
1761+
ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
17621762
goto out;
17631763
}
17641764
info_linear = info_node->info_linear;

0 commit comments

Comments
 (0)