提交 2b327697 编写于 作者: I Ingo Molnar

Merge tag 'perf-urgent-for-mingo-5.4-20190921' of...

Merge tag 'perf-urgent-for-mingo-5.4-20190921' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent

Pull perf/urgent fixes from Arnaldo Carvalho de Melo:

perf tests:

  Jiri Olsa:

  - Fix 'make -C tools/perf build-test' static build entry.

perf record:

  Jiri Olsa:

  - Fix segfault in cpu_cache_level__read() when reading CPU topology.

session:

  Mamatha Inamdar:

  - Properly propagate error when reading a perf.data file, it may
    not exist or the user may not have permissions, etc.

perf probe:

  Masami Hiramatsu:

  - Skip same probe address for a given line.

  - Clear tev->nargs in clear_probe_trace_event(), fixing segfault.

tools headers UAPI:

  Arnaldo Carvalho de Melo:

  - Sync headers, among them prctl.h, that introduces two new options
    that are now supported in the 'perf trace' prctl syscall args
    beautifiers.
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: NIngo Molnar <mingo@kernel.org>
...@@ -2239,7 +2239,7 @@ static void __perf_event_disable(struct perf_event *event, ...@@ -2239,7 +2239,7 @@ static void __perf_event_disable(struct perf_event *event,
* *
* If event->ctx is a cloned context, callers must make sure that * If event->ctx is a cloned context, callers must make sure that
* every task struct that event->ctx->task could possibly point to * every task struct that event->ctx->task could possibly point to
* remains valid. This condition is satisifed when called through * remains valid. This condition is satisfied when called through
* perf_event_for_each_child or perf_event_for_each because they * perf_event_for_each_child or perf_event_for_each because they
* hold the top-level event's child_mutex, so any descendant that * hold the top-level event's child_mutex, so any descendant that
* goes to exit will block in perf_event_exit_event(). * goes to exit will block in perf_event_exit_event().
...@@ -6054,7 +6054,7 @@ static void perf_sample_regs_intr(struct perf_regs *regs_intr, ...@@ -6054,7 +6054,7 @@ static void perf_sample_regs_intr(struct perf_regs *regs_intr,
* Get remaining task size from user stack pointer. * Get remaining task size from user stack pointer.
* *
* It'd be better to take stack vma map and limit this more * It'd be better to take stack vma map and limit this more
* precisly, but there's no way to get it safely under interrupt, * precisely, but there's no way to get it safely under interrupt,
* so using TASK_SIZE as limit. * so using TASK_SIZE as limit.
*/ */
static u64 perf_ustack_task_size(struct pt_regs *regs) static u64 perf_ustack_task_size(struct pt_regs *regs)
...@@ -6616,7 +6616,7 @@ void perf_prepare_sample(struct perf_event_header *header, ...@@ -6616,7 +6616,7 @@ void perf_prepare_sample(struct perf_event_header *header,
if (sample_type & PERF_SAMPLE_STACK_USER) { if (sample_type & PERF_SAMPLE_STACK_USER) {
/* /*
* Either we need PERF_SAMPLE_STACK_USER bit to be allways * Either we need PERF_SAMPLE_STACK_USER bit to be always
* processed as the last one or have additional check added * processed as the last one or have additional check added
* in case new sample type is added, because we could eat * in case new sample type is added, because we could eat
* up the rest of the sample size. * up the rest of the sample size.
......
...@@ -231,6 +231,8 @@ ...@@ -231,6 +231,8 @@
#define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */ #define X86_FEATURE_VMMCALL ( 8*32+15) /* Prefer VMMCALL to VMCALL */
#define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */ #define X86_FEATURE_XENPV ( 8*32+16) /* "" Xen paravirtual guest */
#define X86_FEATURE_EPT_AD ( 8*32+17) /* Intel Extended Page Table access-dirty bit */ #define X86_FEATURE_EPT_AD ( 8*32+17) /* Intel Extended Page Table access-dirty bit */
#define X86_FEATURE_VMCALL ( 8*32+18) /* "" Hypervisor supports the VMCALL instruction */
#define X86_FEATURE_VMW_VMMCALL ( 8*32+19) /* "" VMware prefers VMMCALL hypercall instruction */
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EBX), word 9 */
#define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/ #define X86_FEATURE_FSGSBASE ( 9*32+ 0) /* RDFSBASE, WRFSBASE, RDGSBASE, WRGSBASE instructions*/
...@@ -354,6 +356,7 @@ ...@@ -354,6 +356,7 @@
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
#define X86_FEATURE_AVX512_VP2INTERSECT (18*32+ 8) /* AVX-512 Intersect for D/Q */
#define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */ #define X86_FEATURE_MD_CLEAR (18*32+10) /* VERW clears CPU buffers */
#define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */ #define X86_FEATURE_TSX_FORCE_ABORT (18*32+13) /* "" TSX_FORCE_ABORT */
#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ #define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#define _UAPI_ASM_X86_UNISTD_H #define _UAPI_ASM_X86_UNISTD_H
/* x32 syscall flag bit */ /* x32 syscall flag bit */
#define __X32_SYSCALL_BIT 0x40000000 #define __X32_SYSCALL_BIT 0x40000000UL
#ifndef __KERNEL__ #ifndef __KERNEL__
# ifdef __i386__ # ifdef __i386__
......
...@@ -569,7 +569,7 @@ __SYSCALL(__NR_semget, sys_semget) ...@@ -569,7 +569,7 @@ __SYSCALL(__NR_semget, sys_semget)
__SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl) __SC_COMP(__NR_semctl, sys_semctl, compat_sys_semctl)
#if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32 #if defined(__ARCH_WANT_TIME32_SYSCALLS) || __BITS_PER_LONG != 32
#define __NR_semtimedop 192 #define __NR_semtimedop 192
__SC_COMP(__NR_semtimedop, sys_semtimedop, sys_semtimedop_time32) __SC_3264(__NR_semtimedop, sys_semtimedop_time32, sys_semtimedop)
#endif #endif
#define __NR_semop 193 #define __NR_semop 193
__SYSCALL(__NR_semop, sys_semop) __SYSCALL(__NR_semop, sys_semop)
......
...@@ -181,7 +181,7 @@ struct prctl_mm_map { ...@@ -181,7 +181,7 @@ struct prctl_mm_map {
#define PR_GET_THP_DISABLE 42 #define PR_GET_THP_DISABLE 42
/* /*
* Tell the kernel to start/stop helping userspace manage bounds tables. * No longer implemented, but left here to ensure the numbers stay reserved:
*/ */
#define PR_MPX_ENABLE_MANAGEMENT 43 #define PR_MPX_ENABLE_MANAGEMENT 43
#define PR_MPX_DISABLE_MANAGEMENT 44 #define PR_MPX_DISABLE_MANAGEMENT 44
...@@ -229,4 +229,9 @@ struct prctl_mm_map { ...@@ -229,4 +229,9 @@ struct prctl_mm_map {
# define PR_PAC_APDBKEY (1UL << 3) # define PR_PAC_APDBKEY (1UL << 3)
# define PR_PAC_APGAKEY (1UL << 4) # define PR_PAC_APGAKEY (1UL << 4)
/* Tagged user address controls for arm64 */
#define PR_SET_TAGGED_ADDR_CTRL 55
#define PR_GET_TAGGED_ADDR_CTRL 56
# define PR_TAGGED_ADDR_ENABLE (1UL << 0)
#endif /* _LINUX_PRCTL_H */ #endif /* _LINUX_PRCTL_H */
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h> #include <errno.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/err.h>
struct perf_annotate { struct perf_annotate {
struct perf_tool tool; struct perf_tool tool;
...@@ -584,8 +585,8 @@ int cmd_annotate(int argc, const char **argv) ...@@ -584,8 +585,8 @@ int cmd_annotate(int argc, const char **argv)
data.path = input_name; data.path = input_name;
annotate.session = perf_session__new(&data, false, &annotate.tool); annotate.session = perf_session__new(&data, false, &annotate.tool);
if (annotate.session == NULL) if (IS_ERR(annotate.session))
return -1; return PTR_ERR(annotate.session);
annotate.has_br_stack = perf_header__has_feat(&annotate.session->header, annotate.has_br_stack = perf_header__has_feat(&annotate.session->header,
HEADER_BRANCH_STACK); HEADER_BRANCH_STACK);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "util/util.h" #include "util/util.h"
#include "util/probe-file.h" #include "util/probe-file.h"
#include <linux/string.h> #include <linux/string.h>
#include <linux/err.h>
static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid) static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
{ {
...@@ -422,8 +423,8 @@ int cmd_buildid_cache(int argc, const char **argv) ...@@ -422,8 +423,8 @@ int cmd_buildid_cache(int argc, const char **argv)
data.force = force; data.force = force;
session = perf_session__new(&data, false, NULL); session = perf_session__new(&data, false, NULL);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
} }
if (symbol__init(session ? &session->header.env : NULL) < 0) if (symbol__init(session ? &session->header.env : NULL) < 0)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "util/symbol.h" #include "util/symbol.h"
#include "util/data.h" #include "util/data.h"
#include <errno.h> #include <errno.h>
#include <linux/err.h>
static int sysfs__fprintf_build_id(FILE *fp) static int sysfs__fprintf_build_id(FILE *fp)
{ {
...@@ -65,8 +66,8 @@ static int perf_session__list_build_ids(bool force, bool with_hits) ...@@ -65,8 +66,8 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
goto out; goto out;
session = perf_session__new(&data, false, &build_id__mark_dso_hit_ops); session = perf_session__new(&data, false, &build_id__mark_dso_hit_ops);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
/* /*
* We take all buildids when the file contains AUX area tracing data * We take all buildids when the file contains AUX area tracing data
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <errno.h> #include <errno.h>
#include <inttypes.h> #include <inttypes.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/err.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
...@@ -2781,8 +2782,9 @@ static int perf_c2c__report(int argc, const char **argv) ...@@ -2781,8 +2782,9 @@ static int perf_c2c__report(int argc, const char **argv)
} }
session = perf_session__new(&data, 0, &c2c.tool); session = perf_session__new(&data, 0, &c2c.tool);
if (session == NULL) { if (IS_ERR(session)) {
pr_debug("No memory for session\n"); err = PTR_ERR(session);
pr_debug("Error creating perf session\n");
goto out; goto out;
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "util/time-utils.h" #include "util/time-utils.h"
#include "util/annotate.h" #include "util/annotate.h"
#include "util/map.h" #include "util/map.h"
#include <linux/err.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include <subcmd/pager.h> #include <subcmd/pager.h>
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
...@@ -1153,9 +1154,9 @@ static int check_file_brstack(void) ...@@ -1153,9 +1154,9 @@ static int check_file_brstack(void)
data__for_each_file(i, d) { data__for_each_file(i, d) {
d->session = perf_session__new(&d->data, false, &pdiff.tool); d->session = perf_session__new(&d->data, false, &pdiff.tool);
if (!d->session) { if (IS_ERR(d->session)) {
pr_err("Failed to open %s\n", d->data.path); pr_err("Failed to open %s\n", d->data.path);
return -1; return PTR_ERR(d->session);
} }
has_br_stack = perf_header__has_feat(&d->session->header, has_br_stack = perf_header__has_feat(&d->session->header,
...@@ -1185,9 +1186,9 @@ static int __cmd_diff(void) ...@@ -1185,9 +1186,9 @@ static int __cmd_diff(void)
data__for_each_file(i, d) { data__for_each_file(i, d) {
d->session = perf_session__new(&d->data, false, &pdiff.tool); d->session = perf_session__new(&d->data, false, &pdiff.tool);
if (!d->session) { if (IS_ERR(d->session)) {
ret = PTR_ERR(d->session);
pr_err("Failed to open %s\n", d->data.path); pr_err("Failed to open %s\n", d->data.path);
ret = -1;
goto out_delete; goto out_delete;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "util/session.h" #include "util/session.h"
#include "util/data.h" #include "util/data.h"
#include "util/debug.h" #include "util/debug.h"
#include <linux/err.h>
static int __cmd_evlist(const char *file_name, struct perf_attr_details *details) static int __cmd_evlist(const char *file_name, struct perf_attr_details *details)
{ {
...@@ -28,8 +29,8 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details ...@@ -28,8 +29,8 @@ static int __cmd_evlist(const char *file_name, struct perf_attr_details *details
bool has_tracepoint = false; bool has_tracepoint = false;
session = perf_session__new(&data, 0, NULL); session = perf_session__new(&data, 0, NULL);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
evlist__for_each_entry(session->evlist, pos) { evlist__for_each_entry(session->evlist, pos) {
perf_evsel__fprintf(pos, details, stdout); perf_evsel__fprintf(pos, details, stdout);
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "util/symbol.h" #include "util/symbol.h"
#include "util/synthetic-events.h" #include "util/synthetic-events.h"
#include "util/thread.h" #include "util/thread.h"
#include <linux/err.h>
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
...@@ -835,8 +836,8 @@ int cmd_inject(int argc, const char **argv) ...@@ -835,8 +836,8 @@ int cmd_inject(int argc, const char **argv)
data.path = inject.input_name; data.path = inject.input_name;
inject.session = perf_session__new(&data, true, &inject.tool); inject.session = perf_session__new(&data, true, &inject.tool);
if (inject.session == NULL) if (IS_ERR(inject.session))
return -1; return PTR_ERR(inject.session);
if (zstd_init(&(inject.session->zstd_data), 0) < 0) if (zstd_init(&(inject.session->zstd_data), 0) < 0)
pr_warning("Decompression initialization failed.\n"); pr_warning("Decompression initialization failed.\n");
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "util/tool.h" #include "util/tool.h"
#include "util/callchain.h" #include "util/callchain.h"
#include "util/time-utils.h" #include "util/time-utils.h"
#include <linux/err.h>
#include <subcmd/pager.h> #include <subcmd/pager.h>
#include <subcmd/parse-options.h> #include <subcmd/parse-options.h>
...@@ -1956,8 +1957,8 @@ int cmd_kmem(int argc, const char **argv) ...@@ -1956,8 +1957,8 @@ int cmd_kmem(int argc, const char **argv)
data.path = input_name; data.path = input_name;
kmem_session = session = perf_session__new(&data, false, &perf_kmem); kmem_session = session = perf_session__new(&data, false, &perf_kmem);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
ret = -1; ret = -1;
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <linux/err.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/time64.h> #include <linux/time64.h>
...@@ -1091,9 +1092,9 @@ static int read_events(struct perf_kvm_stat *kvm) ...@@ -1091,9 +1092,9 @@ static int read_events(struct perf_kvm_stat *kvm)
kvm->tool = eops; kvm->tool = eops;
kvm->session = perf_session__new(&file, false, &kvm->tool); kvm->session = perf_session__new(&file, false, &kvm->tool);
if (!kvm->session) { if (IS_ERR(kvm->session)) {
pr_err("Initializing perf session failed\n"); pr_err("Initializing perf session failed\n");
return -1; return PTR_ERR(kvm->session);
} }
symbol__init(&kvm->session->header.env); symbol__init(&kvm->session->header.env);
...@@ -1446,8 +1447,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm, ...@@ -1446,8 +1447,8 @@ static int kvm_events_live(struct perf_kvm_stat *kvm,
* perf session * perf session
*/ */
kvm->session = perf_session__new(&data, false, &kvm->tool); kvm->session = perf_session__new(&data, false, &kvm->tool);
if (kvm->session == NULL) { if (IS_ERR(kvm->session)) {
err = -1; err = PTR_ERR(kvm->session);
goto out; goto out;
} }
kvm->session->evlist = kvm->evlist; kvm->session->evlist = kvm->evlist;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/hash.h> #include <linux/hash.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
#include <linux/err.h>
static struct perf_session *session; static struct perf_session *session;
...@@ -872,9 +873,9 @@ static int __cmd_report(bool display_info) ...@@ -872,9 +873,9 @@ static int __cmd_report(bool display_info)
}; };
session = perf_session__new(&data, false, &eops); session = perf_session__new(&data, false, &eops);
if (!session) { if (IS_ERR(session)) {
pr_err("Initializing perf session failed\n"); pr_err("Initializing perf session failed\n");
return -1; return PTR_ERR(session);
} }
symbol__init(&session->header.env); symbol__init(&session->header.env);
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "util/dso.h" #include "util/dso.h"
#include "util/map.h" #include "util/map.h"
#include "util/symbol.h" #include "util/symbol.h"
#include <linux/err.h>
#define MEM_OPERATION_LOAD 0x1 #define MEM_OPERATION_LOAD 0x1
#define MEM_OPERATION_STORE 0x2 #define MEM_OPERATION_STORE 0x2
...@@ -249,8 +250,8 @@ static int report_raw_events(struct perf_mem *mem) ...@@ -249,8 +250,8 @@ static int report_raw_events(struct perf_mem *mem)
struct perf_session *session = perf_session__new(&data, false, struct perf_session *session = perf_session__new(&data, false,
&mem->tool); &mem->tool);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
if (mem->cpu_list) { if (mem->cpu_list) {
ret = perf_session__cpu_bitmap(session, mem->cpu_list, ret = perf_session__cpu_bitmap(session, mem->cpu_list,
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include <signal.h> #include <signal.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <linux/err.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/time64.h> #include <linux/time64.h>
#include <linux/zalloc.h> #include <linux/zalloc.h>
...@@ -1354,9 +1355,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) ...@@ -1354,9 +1355,9 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
} }
session = perf_session__new(data, false, tool); session = perf_session__new(data, false, tool);
if (session == NULL) { if (IS_ERR(session)) {
pr_err("Perf session creation failed.\n"); pr_err("Perf session creation failed.\n");
return -1; return PTR_ERR(session);
} }
fd = perf_data__fd(data); fd = perf_data__fd(data);
......
...@@ -1269,8 +1269,8 @@ int cmd_report(int argc, const char **argv) ...@@ -1269,8 +1269,8 @@ int cmd_report(int argc, const char **argv)
repeat: repeat:
session = perf_session__new(&data, false, &report.tool); session = perf_session__new(&data, false, &report.tool);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
ret = evswitch__init(&report.evswitch, session->evlist, stderr); ret = evswitch__init(&report.evswitch, session->evlist, stderr);
if (ret) if (ret)
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <api/fs/fs.h> #include <api/fs/fs.h>
#include <perf/cpumap.h> #include <perf/cpumap.h>
#include <linux/time64.h> #include <linux/time64.h>
#include <linux/err.h>
#include <linux/ctype.h> #include <linux/ctype.h>
...@@ -1797,9 +1798,9 @@ static int perf_sched__read_events(struct perf_sched *sched) ...@@ -1797,9 +1798,9 @@ static int perf_sched__read_events(struct perf_sched *sched)
int rc = -1; int rc = -1;
session = perf_session__new(&data, false, &sched->tool); session = perf_session__new(&data, false, &sched->tool);
if (session == NULL) { if (IS_ERR(session)) {
pr_debug("No Memory for session\n"); pr_debug("Error creating perf session");
return -1; return PTR_ERR(session);
} }
symbol__init(&session->header.env); symbol__init(&session->header.env);
...@@ -2989,8 +2990,8 @@ static int perf_sched__timehist(struct perf_sched *sched) ...@@ -2989,8 +2990,8 @@ static int perf_sched__timehist(struct perf_sched *sched)
symbol_conf.use_callchain = sched->show_callchain; symbol_conf.use_callchain = sched->show_callchain;
session = perf_session__new(&data, false, &sched->tool); session = perf_session__new(&data, false, &sched->tool);
if (session == NULL) if (IS_ERR(session))
return -ENOMEM; return PTR_ERR(session);
evlist = session->evlist; evlist = session->evlist;
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <unistd.h> #include <unistd.h>
#include <subcmd/pager.h> #include <subcmd/pager.h>
#include <perf/evlist.h> #include <perf/evlist.h>
#include <linux/err.h>
#include "util/record.h" #include "util/record.h"
#include "util/util.h" #include "util/util.h"
#include "perf.h" #include "perf.h"
...@@ -3083,8 +3084,8 @@ int find_scripts(char **scripts_array, char **scripts_path_array, int num, ...@@ -3083,8 +3084,8 @@ int find_scripts(char **scripts_array, char **scripts_path_array, int num,
int i = 0; int i = 0;
session = perf_session__new(&data, false, NULL); session = perf_session__new(&data, false, NULL);
if (!session) if (IS_ERR(session))
return -1; return PTR_ERR(session);
snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path()); snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path());
...@@ -3754,8 +3755,8 @@ int cmd_script(int argc, const char **argv) ...@@ -3754,8 +3755,8 @@ int cmd_script(int argc, const char **argv)
} }
session = perf_session__new(&data, false, &script.tool); session = perf_session__new(&data, false, &script.tool);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
if (header || header_only) { if (header || header_only) {
script.tool.show_feat_hdr = SHOW_FEAT_HEADER; script.tool.show_feat_hdr = SHOW_FEAT_HEADER;
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <linux/err.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <perf/evlist.h> #include <perf/evlist.h>
...@@ -1436,9 +1437,9 @@ static int __cmd_record(int argc, const char **argv) ...@@ -1436,9 +1437,9 @@ static int __cmd_record(int argc, const char **argv)
} }
session = perf_session__new(data, false, NULL); session = perf_session__new(data, false, NULL);
if (session == NULL) { if (IS_ERR(session)) {
pr_err("Perf session creation failed.\n"); pr_err("Perf session creation failed\n");
return -1; return PTR_ERR(session);
} }
init_features(session); init_features(session);
...@@ -1635,8 +1636,8 @@ static int __cmd_report(int argc, const char **argv) ...@@ -1635,8 +1636,8 @@ static int __cmd_report(int argc, const char **argv)
perf_stat.data.mode = PERF_DATA_MODE_READ; perf_stat.data.mode = PERF_DATA_MODE_READ;
session = perf_session__new(&perf_stat.data, false, &perf_stat.tool); session = perf_session__new(&perf_stat.data, false, &perf_stat.tool);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
perf_stat.session = session; perf_stat.session = session;
stat_config.output = stderr; stat_config.output = stderr;
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "util/tool.h" #include "util/tool.h"
#include "util/data.h" #include "util/data.h"
#include "util/debug.h" #include "util/debug.h"
#include <linux/err.h>
#ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE #ifdef LACKS_OPEN_MEMSTREAM_PROTOTYPE
FILE *open_memstream(char **ptr, size_t *sizeloc); FILE *open_memstream(char **ptr, size_t *sizeloc);
...@@ -1601,8 +1602,8 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name) ...@@ -1601,8 +1602,8 @@ static int __cmd_timechart(struct timechart *tchart, const char *output_name)
&tchart->tool); &tchart->tool);
int ret = -EINVAL; int ret = -EINVAL;
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
symbol__init(&session->header.env); symbol__init(&session->header.env);
......
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/time64.h> #include <linux/time64.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/err.h>
#include <linux/ctype.h> #include <linux/ctype.h>
...@@ -1672,8 +1673,8 @@ int cmd_top(int argc, const char **argv) ...@@ -1672,8 +1673,8 @@ int cmd_top(int argc, const char **argv)
} }
top.session = perf_session__new(NULL, false, NULL); top.session = perf_session__new(NULL, false, NULL);
if (top.session == NULL) { if (IS_ERR(top.session)) {
status = -1; status = PTR_ERR(top.session);
goto out_delete_evlist; goto out_delete_evlist;
} }
......
...@@ -3585,8 +3585,8 @@ static int trace__replay(struct trace *trace) ...@@ -3585,8 +3585,8 @@ static int trace__replay(struct trace *trace)
trace->multiple_threads = true; trace->multiple_threads = true;
session = perf_session__new(&data, false, &trace->tool); session = perf_session__new(&data, false, &trace->tool);
if (session == NULL) if (IS_ERR(session))
return -1; return PTR_ERR(session);
if (trace->opts.target.pid) if (trace->opts.target.pid)
symbol_conf.pid_list_str = strdup(trace->opts.target.pid); symbol_conf.pid_list_str = strdup(trace->opts.target.pid);
......
...@@ -100,7 +100,7 @@ make_install_info := install-info ...@@ -100,7 +100,7 @@ make_install_info := install-info
make_install_pdf := install-pdf make_install_pdf := install-pdf
make_install_prefix := install prefix=/tmp/krava make_install_prefix := install prefix=/tmp/krava
make_install_prefix_slash := install prefix=/tmp/krava/ make_install_prefix_slash := install prefix=/tmp/krava/
make_static := LDFLAGS=-static make_static := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1
# all the NO_* variable combined # all the NO_* variable combined
make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1 make_minimal := NO_LIBPERL=1 NO_LIBPYTHON=1 NO_NEWT=1 NO_GTK2=1
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "session.h" #include "session.h"
#include "evlist.h" #include "evlist.h"
#include "debug.h" #include "debug.h"
#include <linux/err.h>
#define TEMPL "/tmp/perf-test-XXXXXX" #define TEMPL "/tmp/perf-test-XXXXXX"
#define DATA_SIZE 10 #define DATA_SIZE 10
...@@ -39,7 +40,7 @@ static int session_write_header(char *path) ...@@ -39,7 +40,7 @@ static int session_write_header(char *path)
}; };
session = perf_session__new(&data, false, NULL); session = perf_session__new(&data, false, NULL);
TEST_ASSERT_VAL("can't get session", session); TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
session->evlist = perf_evlist__new_default(); session->evlist = perf_evlist__new_default();
TEST_ASSERT_VAL("can't get evlist", session->evlist); TEST_ASSERT_VAL("can't get evlist", session->evlist);
...@@ -70,7 +71,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) ...@@ -70,7 +71,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map)
int i; int i;
session = perf_session__new(&data, false, NULL); session = perf_session__new(&data, false, NULL);
TEST_ASSERT_VAL("can't get session", session); TEST_ASSERT_VAL("can't get session", !IS_ERR(session));
/* On platforms with large numbers of CPUs process_cpu_topology() /* On platforms with large numbers of CPUs process_cpu_topology()
* might issue an error while reading the perf.data file section * might issue an error while reading the perf.data file section
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "machine.h" #include "machine.h"
#include "config.h" #include "config.h"
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/err.h>
#define pr_N(n, fmt, ...) \ #define pr_N(n, fmt, ...) \
eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__) eprintf(n, debug_data_convert, fmt, ##__VA_ARGS__)
...@@ -1619,8 +1620,10 @@ int bt_convert__perf2ctf(const char *input, const char *path, ...@@ -1619,8 +1620,10 @@ int bt_convert__perf2ctf(const char *input, const char *path,
err = -1; err = -1;
/* perf.data session */ /* perf.data session */
session = perf_session__new(&data, 0, &c.tool); session = perf_session__new(&data, 0, &c.tool);
if (!session) if (IS_ERR(session)) {
err = PTR_ERR(session);
goto free_writer; goto free_writer;
}
if (c.queue_size) { if (c.queue_size) {
ordered_events__set_alloc_size(&session->ordered_events, ordered_events__set_alloc_size(&session->ordered_events,
......
...@@ -1073,7 +1073,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev ...@@ -1073,7 +1073,7 @@ static int cpu_cache_level__read(struct cpu_cache_level *cache, u32 cpu, u16 lev
scnprintf(file, PATH_MAX, "%s/shared_cpu_list", path); scnprintf(file, PATH_MAX, "%s/shared_cpu_list", path);
if (sysfs__read_str(file, &cache->map, &len)) { if (sysfs__read_str(file, &cache->map, &len)) {
zfree(&cache->map); zfree(&cache->size);
zfree(&cache->type); zfree(&cache->type);
return -1; return -1;
} }
......
...@@ -2331,6 +2331,7 @@ void clear_probe_trace_event(struct probe_trace_event *tev) ...@@ -2331,6 +2331,7 @@ void clear_probe_trace_event(struct probe_trace_event *tev)
} }
} }
zfree(&tev->args); zfree(&tev->args);
tev->nargs = 0;
} }
struct kprobe_blacklist_node { struct kprobe_blacklist_node {
......
...@@ -1245,6 +1245,17 @@ static int expand_probe_args(Dwarf_Die *sc_die, struct probe_finder *pf, ...@@ -1245,6 +1245,17 @@ static int expand_probe_args(Dwarf_Die *sc_die, struct probe_finder *pf,
return n; return n;
} }
static bool trace_event_finder_overlap(struct trace_event_finder *tf)
{
int i;
for (i = 0; i < tf->ntevs; i++) {
if (tf->pf.addr == tf->tevs[i].point.address)
return true;
}
return false;
}
/* Add a found probe point into trace event list */ /* Add a found probe point into trace event list */
static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf) static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
{ {
...@@ -1255,6 +1266,14 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf) ...@@ -1255,6 +1266,14 @@ static int add_probe_trace_event(Dwarf_Die *sc_die, struct probe_finder *pf)
struct perf_probe_arg *args = NULL; struct perf_probe_arg *args = NULL;
int ret, i; int ret, i;
/*
* For some reason (e.g. different column assigned to same address)
* This callback can be called with the address which already passed.
* Ignore it first.
*/
if (trace_event_finder_overlap(tf))
return 0;
/* Check number of tevs */ /* Check number of tevs */
if (tf->ntevs == tf->max_tevs) { if (tf->ntevs == tf->max_tevs) {
pr_warning("Too many( > %d) probe point found.\n", pr_warning("Too many( > %d) probe point found.\n",
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "../perf.h" #include "../perf.h"
#include "arch/common.h" #include "arch/common.h"
#include <internal/lib.h> #include <internal/lib.h>
#include <linux/err.h>
#ifdef HAVE_ZSTD_SUPPORT #ifdef HAVE_ZSTD_SUPPORT
static int perf_session__process_compressed_event(struct perf_session *session, static int perf_session__process_compressed_event(struct perf_session *session,
...@@ -187,6 +188,7 @@ static int ordered_events__deliver_event(struct ordered_events *oe, ...@@ -187,6 +188,7 @@ static int ordered_events__deliver_event(struct ordered_events *oe,
struct perf_session *perf_session__new(struct perf_data *data, struct perf_session *perf_session__new(struct perf_data *data,
bool repipe, struct perf_tool *tool) bool repipe, struct perf_tool *tool)
{ {
int ret = -ENOMEM;
struct perf_session *session = zalloc(sizeof(*session)); struct perf_session *session = zalloc(sizeof(*session));
if (!session) if (!session)
...@@ -201,13 +203,15 @@ struct perf_session *perf_session__new(struct perf_data *data, ...@@ -201,13 +203,15 @@ struct perf_session *perf_session__new(struct perf_data *data,
perf_env__init(&session->header.env); perf_env__init(&session->header.env);
if (data) { if (data) {
if (perf_data__open(data)) ret = perf_data__open(data);
if (ret < 0)
goto out_delete; goto out_delete;
session->data = data; session->data = data;
if (perf_data__is_read(data)) { if (perf_data__is_read(data)) {
if (perf_session__open(session) < 0) ret = perf_session__open(session);
if (ret < 0)
goto out_delete; goto out_delete;
/* /*
...@@ -222,8 +226,11 @@ struct perf_session *perf_session__new(struct perf_data *data, ...@@ -222,8 +226,11 @@ struct perf_session *perf_session__new(struct perf_data *data,
perf_evlist__init_trace_event_sample_raw(session->evlist); perf_evlist__init_trace_event_sample_raw(session->evlist);
/* Open the directory data. */ /* Open the directory data. */
if (data->is_dir && perf_data__open_dir(data)) if (data->is_dir) {
ret = perf_data__open_dir(data);
if (ret)
goto out_delete; goto out_delete;
}
} }
} else { } else {
session->machines.host.env = &perf_env; session->machines.host.env = &perf_env;
...@@ -256,7 +263,7 @@ struct perf_session *perf_session__new(struct perf_data *data, ...@@ -256,7 +263,7 @@ struct perf_session *perf_session__new(struct perf_data *data,
out_delete: out_delete:
perf_session__delete(session); perf_session__delete(session);
out: out:
return NULL; return ERR_PTR(ret);
} }
static void perf_session__delete_threads(struct perf_session *session) static void perf_session__delete_threads(struct perf_session *session)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册