Commit a8a31fdc authored by Linus Torvalds's avatar Linus Torvalds

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()
parents 1e1ac1cb f3a519e4
...@@ -627,7 +627,7 @@ static struct topa *topa_alloc(int cpu, gfp_t gfp) ...@@ -627,7 +627,7 @@ static struct topa *topa_alloc(int cpu, gfp_t gfp)
* link as the 2nd entry in the table * link as the 2nd entry in the table
*/ */
if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) { if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries)) {
TOPA_ENTRY(&tp->topa, 1)->base = page_to_phys(p); TOPA_ENTRY(&tp->topa, 1)->base = page_to_phys(p) >> TOPA_SHIFT;
TOPA_ENTRY(&tp->topa, 1)->end = 1; TOPA_ENTRY(&tp->topa, 1)->end = 1;
} }
......
...@@ -5607,8 +5607,10 @@ static void perf_mmap_close(struct vm_area_struct *vma) ...@@ -5607,8 +5607,10 @@ static void perf_mmap_close(struct vm_area_struct *vma)
perf_pmu_output_stop(event); perf_pmu_output_stop(event);
/* now it's safe to free the pages */ /* now it's safe to free the pages */
atomic_long_sub(rb->aux_nr_pages, &mmap_user->locked_vm); if (!rb->aux_mmap_locked)
atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm); atomic_long_sub(rb->aux_nr_pages, &mmap_user->locked_vm);
else
atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);
/* this has to be the last one */ /* this has to be the last one */
rb_free_aux(rb); rb_free_aux(rb);
...@@ -6947,7 +6949,7 @@ static void __perf_event_output_stop(struct perf_event *event, void *data) ...@@ -6947,7 +6949,7 @@ static void __perf_event_output_stop(struct perf_event *event, void *data)
static int __perf_pmu_output_stop(void *info) static int __perf_pmu_output_stop(void *info)
{ {
struct perf_event *event = info; struct perf_event *event = info;
struct pmu *pmu = event->pmu; struct pmu *pmu = event->ctx->pmu;
struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context); struct perf_cpu_context *cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
struct remote_output ro = { struct remote_output ro = {
.rb = event->rb, .rb = event->rb,
......
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#define SVM_EXIT_MWAIT 0x08b #define SVM_EXIT_MWAIT 0x08b
#define SVM_EXIT_MWAIT_COND 0x08c #define SVM_EXIT_MWAIT_COND 0x08c
#define SVM_EXIT_XSETBV 0x08d #define SVM_EXIT_XSETBV 0x08d
#define SVM_EXIT_RDPRU 0x08e
#define SVM_EXIT_NPF 0x400 #define SVM_EXIT_NPF 0x400
#define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401 #define SVM_EXIT_AVIC_INCOMPLETE_IPI 0x401
#define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402 #define SVM_EXIT_AVIC_UNACCELERATED_ACCESS 0x402
......
...@@ -86,6 +86,8 @@ ...@@ -86,6 +86,8 @@
#define EXIT_REASON_PML_FULL 62 #define EXIT_REASON_PML_FULL 62
#define EXIT_REASON_XSAVES 63 #define EXIT_REASON_XSAVES 63
#define EXIT_REASON_XRSTORS 64 #define EXIT_REASON_XRSTORS 64
#define EXIT_REASON_UMWAIT 67
#define EXIT_REASON_TPAUSE 68
#define VMX_EXIT_REASONS \ #define VMX_EXIT_REASONS \
{ EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \ { EXIT_REASON_EXCEPTION_NMI, "EXCEPTION_NMI" }, \
...@@ -144,7 +146,9 @@ ...@@ -144,7 +146,9 @@
{ EXIT_REASON_RDSEED, "RDSEED" }, \ { EXIT_REASON_RDSEED, "RDSEED" }, \
{ EXIT_REASON_PML_FULL, "PML_FULL" }, \ { EXIT_REASON_PML_FULL, "PML_FULL" }, \
{ EXIT_REASON_XSAVES, "XSAVES" }, \ { EXIT_REASON_XSAVES, "XSAVES" }, \
{ EXIT_REASON_XRSTORS, "XRSTORS" } { EXIT_REASON_XRSTORS, "XRSTORS" }, \
{ EXIT_REASON_UMWAIT, "UMWAIT" }, \
{ EXIT_REASON_TPAUSE, "TPAUSE" }
#define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1 #define VMX_ABORT_SAVE_GUEST_MSR_FAIL 1
#define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2 #define VMX_ABORT_LOAD_HOST_PDPTE_FAIL 2
......
...@@ -999,6 +999,7 @@ struct kvm_ppc_resize_hpt { ...@@ -999,6 +999,7 @@ struct kvm_ppc_resize_hpt {
#define KVM_CAP_ARM_PTRAUTH_GENERIC 172 #define KVM_CAP_ARM_PTRAUTH_GENERIC 172
#define KVM_CAP_PMU_EVENT_FILTER 173 #define KVM_CAP_PMU_EVENT_FILTER 173
#define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174 #define KVM_CAP_ARM_IRQ_LINE_LAYOUT_2 174
#define KVM_CAP_HYPERV_DIRECT_TLBFLUSH 175
#ifdef KVM_CAP_IRQ_ROUTING #ifdef KVM_CAP_IRQ_ROUTING
...@@ -1145,6 +1146,7 @@ struct kvm_dirty_tlb { ...@@ -1145,6 +1146,7 @@ struct kvm_dirty_tlb {
#define KVM_REG_S390 0x5000000000000000ULL #define KVM_REG_S390 0x5000000000000000ULL
#define KVM_REG_ARM64 0x6000000000000000ULL #define KVM_REG_ARM64 0x6000000000000000ULL
#define KVM_REG_MIPS 0x7000000000000000ULL #define KVM_REG_MIPS 0x7000000000000000ULL
#define KVM_REG_RISCV 0x8000000000000000ULL
#define KVM_REG_SIZE_SHIFT 52 #define KVM_REG_SIZE_SHIFT 52
#define KVM_REG_SIZE_MASK 0x00f0000000000000ULL #define KVM_REG_SIZE_MASK 0x00f0000000000000ULL
......
...@@ -33,8 +33,31 @@ ...@@ -33,8 +33,31 @@
#define CLONE_NEWNET 0x40000000 /* New network namespace */ #define CLONE_NEWNET 0x40000000 /* New network namespace */
#define CLONE_IO 0x80000000 /* Clone io context */ #define CLONE_IO 0x80000000 /* Clone io context */
/* #ifndef __ASSEMBLY__
* Arguments for the clone3 syscall /**
* struct clone_args - arguments for the clone3 syscall
* @flags: Flags for the new process as listed above.
* All flags are valid except for CSIGNAL and
* CLONE_DETACHED.
* @pidfd: If CLONE_PIDFD is set, a pidfd will be
* returned in this argument.
* @child_tid: If CLONE_CHILD_SETTID is set, the TID of the
* child process will be returned in the child's
* memory.
* @parent_tid: If CLONE_PARENT_SETTID is set, the TID of
* the child process will be returned in the
* parent's memory.
* @exit_signal: The exit_signal the parent process will be
* sent when the child exits.
* @stack: Specify the location of the stack for the
* child process.
* @stack_size: The size of the stack for the child process.
* @tls: If CLONE_SETTLS is set, the tls descriptor
* is set to tls.
*
* The structure is versioned by size and thus extensible.
* New struct members must go at the end of the struct and
* must be properly 64bit aligned.
*/ */
struct clone_args { struct clone_args {
__aligned_u64 flags; __aligned_u64 flags;
...@@ -46,6 +69,9 @@ struct clone_args { ...@@ -46,6 +69,9 @@ struct clone_args {
__aligned_u64 stack_size; __aligned_u64 stack_size;
__aligned_u64 tls; __aligned_u64 tls;
}; };
#endif
#define CLONE_ARGS_SIZE_VER0 64 /* sizeof first published struct */
/* /*
* Scheduling policies * Scheduling policies
......
...@@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source) ...@@ -2635,6 +2635,7 @@ static int build_cl_output(char *cl_sort, bool no_source)
bool add_sym = false; bool add_sym = false;
bool add_dso = false; bool add_dso = false;
bool add_src = false; bool add_src = false;
int ret = 0;
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
...@@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source) ...@@ -2653,7 +2654,8 @@ static int build_cl_output(char *cl_sort, bool no_source)
add_dso = true; add_dso = true;
} else if (strcmp(tok, "offset")) { } else if (strcmp(tok, "offset")) {
pr_err("unrecognized sort token: %s\n", tok); pr_err("unrecognized sort token: %s\n", tok);
return -EINVAL; ret = -EINVAL;
goto err;
} }
} }
...@@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source) ...@@ -2676,13 +2678,15 @@ static int build_cl_output(char *cl_sort, bool no_source)
add_sym ? "symbol," : "", add_sym ? "symbol," : "",
add_dso ? "dso," : "", add_dso ? "dso," : "",
add_src ? "cl_srcline," : "", add_src ? "cl_srcline," : "",
"node") < 0) "node") < 0) {
return -ENOMEM; ret = -ENOMEM;
goto err;
}
c2c.show_src = add_src; c2c.show_src = add_src;
err:
free(buf); free(buf);
return 0; return ret;
} }
static int setup_coalesce(const char *coalesce, bool no_source) static int setup_coalesce(const char *coalesce, bool no_source)
......
...@@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags) ...@@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
new = realloc(new_flags, len + strlen(cpt) + 2); new = realloc(new_flags, len + strlen(cpt) + 2);
if (new == NULL) { if (new == NULL) {
free(new_flags); free(new_flags);
free(orig_flags);
return NULL; return NULL;
} }
......
...@@ -2,7 +2,7 @@ jvmti-y += libjvmti.o ...@@ -2,7 +2,7 @@ jvmti-y += libjvmti.o
jvmti-y += jvmti_agent.o jvmti-y += jvmti_agent.o
# For strlcpy # For strlcpy
jvmti-y += libstring.o jvmti-y += libstring.o libctype.o
CFLAGS_jvmti = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux CFLAGS_jvmti = -fPIC -DPIC -I$(JDIR)/include -I$(JDIR)/include/linux
CFLAGS_REMOVE_jvmti = -Wmissing-declarations CFLAGS_REMOVE_jvmti = -Wmissing-declarations
...@@ -15,3 +15,7 @@ CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PE ...@@ -15,3 +15,7 @@ CFLAGS_libstring.o += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PE
$(OUTPUT)jvmti/libstring.o: ../lib/string.c FORCE $(OUTPUT)jvmti/libstring.o: ../lib/string.c FORCE
$(call rule_mkdir) $(call rule_mkdir)
$(call if_changed_dep,cc_o_c) $(call if_changed_dep,cc_o_c)
$(OUTPUT)jvmti/libctype.o: ../lib/ctype.c FORCE
$(call rule_mkdir)
$(call if_changed_dep,cc_o_c)
...@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym, ...@@ -1758,7 +1758,7 @@ static int symbol__disassemble_bpf(struct symbol *sym,
info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env, info_node = perf_env__find_bpf_prog_info(dso->bpf_prog.env,
dso->bpf_prog.id); dso->bpf_prog.id);
if (!info_node) { if (!info_node) {
return SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF; ret = SYMBOL_ANNOTATE_ERRNO__BPF_MISSING_BTF;
goto out; goto out;
} }
info_linear = info_node->info_linear; info_linear = info_node->info_linear;
......
...@@ -101,14 +101,16 @@ static int copyfile_mode_ns(const char *from, const char *to, mode_t mode, ...@@ -101,14 +101,16 @@ static int copyfile_mode_ns(const char *from, const char *to, mode_t mode,
if (tofd < 0) if (tofd < 0)
goto out; goto out;
if (fchmod(tofd, mode))
goto out_close_to;
if (st.st_size == 0) { /* /proc? do it slowly... */ if (st.st_size == 0) { /* /proc? do it slowly... */
err = slow_copyfile(from, tmp, nsi); err = slow_copyfile(from, tmp, nsi);
if (!err && fchmod(tofd, mode))
err = -1;
goto out_close_to; goto out_close_to;
} }
if (fchmod(tofd, mode))
goto out_close_to;
nsinfo__mountns_enter(nsi, &nsc); nsinfo__mountns_enter(nsi, &nsc);
fromfd = open(from, O_RDONLY); fromfd = open(from, O_RDONLY);
nsinfo__mountns_exit(&nsc); nsinfo__mountns_exit(&nsc);
......
...@@ -1659,7 +1659,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list, ...@@ -1659,7 +1659,7 @@ struct evsel *perf_evlist__reset_weak_group(struct evlist *evsel_list,
is_open = false; is_open = false;
if (c2->leader == leader) { if (c2->leader == leader) {
if (is_open) if (is_open)
perf_evsel__close(&evsel->core); perf_evsel__close(&c2->core);
c2->leader = c2; c2->leader = c2;
c2->core.nr_members = 0; c2->core.nr_members = 0;
} }
......
...@@ -1296,8 +1296,10 @@ static int build_mem_topology(struct memory_node *nodes, u64 size, u64 *cntp) ...@@ -1296,8 +1296,10 @@ static int build_mem_topology(struct memory_node *nodes, u64 size, u64 *cntp)
continue; continue;
if (WARN_ONCE(cnt >= size, if (WARN_ONCE(cnt >= size,
"failed to write MEM_TOPOLOGY, way too many nodes\n")) "failed to write MEM_TOPOLOGY, way too many nodes\n")) {
closedir(dir);
return -1; return -1;
}
ret = memory_node__read(&nodes[cnt++], idx); ret = memory_node__read(&nodes[cnt++], idx);
} }
......
...@@ -154,8 +154,10 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat) ...@@ -154,8 +154,10 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat)
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
continue; continue;
if (!match_pat(d->d_name, pat)) if (!match_pat(d->d_name, pat)) {
return -2; ret = -2;
break;
}
scnprintf(namebuf, sizeof(namebuf), "%s/%s", scnprintf(namebuf, sizeof(namebuf), "%s/%s",
path, d->d_name); path, d->d_name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment