perf/core improvements and fixes
Arnaldo Carvalho de Melo
maintainerHi Ingo,
Please consider pulling, this is on top of my previous pull
request (perf-core-for-mingo-20160516).
- Arnaldo
The following changes since commit a29d5c9b8167dbc21a7ca8c0302e3799f9063b4e:
perf tools: Separate accounting of contexts and real addresses in a stack trace (2016-05-16 23:11:54 -0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-core-for-mingo-20160519
for you to fetch changes up to f978a7b47e5a31d4057187153f71e95b24455e54:
perf tools: Set buildid dir under symfs when --symfs is provided (2016-05-19 19:04:36 -0300)
----------------------------------------------------------------
perf/core improvements and fixes:
User visible:
- We should not use the current value of the kernel.perf_event_max_stack as the default value for --max-stack in tools that can process perf.data files, they will only match if that sysctl wasn't changed from its default value at the time the perf.data file was recorded, fix it.
This fixes a bug where a 'perf record -a --call-graph dwarf ; perf report' produces a glibc invalid free backtrace (Arnaldo Carvalho de Melo)
- Provide a better warning when running 'perf trace' on a system where the kernel.kptr_restrict is set to 1, similar to the one produced by 'perf record', noticed on ubuntu 16.04 where this is the default kptr_restrict setting. (Arnaldo Carvalho de Melo)
- Fix ordering of instructions in the annotation code, noticed when annotating ARM binaries, now that table is auto-ordered at first use, to avoid more such problems (Chris Ryder)
- Fix searching the vdso image to support cross-platform analysis (He Kuang)
- Set buildid dir under symfs when --symfs is provided (He Kuang)
- Fix the 'exit_group()' syscall output in 'perf trace' (Arnaldo Carvalho de Melo)
- Only auto set call-graph to "dwarf" in 'perf trace' when syscalls are being traced (Arnaldo Carvalho de Melo)
----------------------------------------------------------------
Arnaldo Carvalho de Melo (7):
perf machine: Do not bail out if not managing to read ref reloc symbol perf trace: Warn when trying to resolve kernel addresses with kptr_restrict=1 perf top: Use machine->kptr_restrict_warned
perf trace: Fix exit_group() formatting
perf callchain: Stop validating callchains by the max_stack sysctl perf tools: Fix usage of max_stack sysctl
perf trace: Only auto set call-graph to "dwarf" when syscalls are being traced
Chris Ryder (2):
perf annotate: Fix identification of ARM blt and bls instructions perf annotate: Sort list of recognised instructions
He Kuang (2):
perf tools: Find vdso supporting cross-platform analysis perf tools: Set buildid dir under symfs when --symfs is provided
tools/perf/Documentation/perf-report.txt | 2 +- tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/Documentation/perf-trace.txt | 3 +- tools/perf/builtin-annotate.c | 5 +-- tools/perf/builtin-diff.c | 5 +-- tools/perf/builtin-report.c | 7 ++-- tools/perf/builtin-script.c | 7 ++-- tools/perf/builtin-timechart.c | 5 +-- tools/perf/builtin-top.c | 6 ++-- tools/perf/builtin-trace.c | 26 +++++++++++--- tools/perf/util/annotate.c | 30 ++++++++++++---- tools/perf/util/db-export.c | 3 +- tools/perf/util/dso.c | 4 +-- tools/perf/util/machine.c | 35 ++++++------------- tools/perf/util/machine.h | 1 + .../perf/util/scripting-engines/trace-event-perl.c | 3 +- tools/perf/util/symbol.c | 23 +++++++++++++ tools/perf/util/symbol.h | 2 ++ tools/perf/util/top.h | 1 - tools/perf/util/vdso.c | 40 ++++++++++++++++++++-- 20 files changed, 146 insertions(+), 64 deletions(-)
Arnaldo Carvalho de Melo
maintainerPATCH 1/11 perf tools: Find vdso supporting cross-platform analysis
From: He Kuang <[email protected]>
There's a problem in machine__findnew_vdso(), vdso buildid generated by a 32-bit machine stores it with the name 'vdso', but when processing buildid on a 64-bit machine with the same 'perf.data', perf will search for vdso named as 'vdso32' and get failed.
This patch tries to find the exsiting dsos in machine->dsos by thread dso_type. 64-bit thread tries to find vdso with name 'vdso', because all 64-bit vdso is named as that. 32-bit thread first tries to find vdso with name 'vdso32' if this thread was run on 64-bit machine, if failed, then it tries 'vdso' which indicates that the thread was run on 32-bit machine when recording.
--- tools/perf/util/vdso.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-)
tools/perf/util/vdso.c +37 -3
@@ -134,8 +134,6 @@ static struct dso *__machine__addnew_vdso(struct machine *machine, const char *sreturn dso; } -#if BITS_PER_LONG ==64 -static enum dso_type machine__thread_dso_type (struct machine *machine,struct thread *thread) {
@@ -156,6 +154,8 @@ static enum dso_type machine__thread_dso_type(struct machine *machine,return dso_type; } +#if BITS_PER_LONG ==64 +static int vdso__do_copy_compat (FILE *f,int fd) {char buf[4096 ];
@@ -283,8 +283,38 @@ static int __machine__findnew_vdso_compat(struct machine *machine,#endif +static struct dso *machine__find_vdso (struct machine *machine, +struct thread *thread) +{ +struct dso *dso =NULL ; +enum dso_type dso_type; + + dso_type =machine__thread_dso_type (machine, thread); +switch (dso_type) { +case DSO__TYPE_32BIT : + dso =__dsos__find (&machine->dsos,DSO__NAME_VDSO32 , true); +if (!dso) { + dso =__dsos__find (&machine->dsos,DSO__NAME_VDSO , + true); +if (dso_type !=dso__type (dso, machine)) + dso =NULL ; + } +break ; +case DSO__TYPE_X32BIT : + dso =__dsos__find (&machine->dsos,DSO__NAME_VDSOX32 , true); +break ; +case DSO__TYPE_64BIT : +case DSO__TYPE_UNKNOWN : +default : + dso =__dsos__find (&machine->dsos,DSO__NAME_VDSO , true); +break ; + } + +return dso; +} +struct dso *machine__findnew_vdso (struct machine *machine, -struct thread *thread__maybe_unused ) +struct thread *thread) {struct vdso_info *vdso_info;struct dso *dso =NULL ;
@@ -297,6 +327,10 @@ struct dso *machine__findnew_vdso(struct machine *machine,if (!vdso_info) goto out_unlock; + dso =machine__find_vdso (machine, thread); +if (dso) + goto out_unlock; +#if BITS_PER_LONG ==64 if (__machine__findnew_vdso_compat (machine, thread, vdso_info, &dso)) goto out_unlock;
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 2/11 perf machine: Do not bail out if not managing to read ref reloc symbol
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
This means the user can't access /proc/kallsyms, for instance, because /proc/sys/kernel/kptr_restrict is set to 1.
Instead leave the ref_reloc_sym as NULL and code using it will cope.
This allows 'perf trace' to work on such systems for !root, the only issue would be when trying to resolve kernel symbols, which happens, for instance, in some libtracevent plugins. A warning for that case will be provided in the next patch in this series.
Noticed in Ubuntu 16.04, that comes with kptr_restrict=1.
--- tools/perf/util/machine.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/perf/util/machine.c +5 -4
@@ -1135,10 +1135,10 @@ int machine__create_kernel_maps(struct machine *machine) {struct dso *kernel =machine__get_kernel (machine);const char *name; -u64 addr =machine__get_running_kernel_start (machine, &name); +u64 addr;int ret; -if (!addr || kernel ==NULL ) +if (kernel ==NULL )return -1 ; ret =__machine__create_kernel_maps (machine, kernel);
@@ -1160,8 +1160,9 @@ int machine__create_kernel_maps(struct machine *machine)*/ map_groups__fixup_end (&machine->kmaps); -if (maps__set_kallsyms_ref_reloc_sym (machine->vmlinux_maps, name, - addr)) { + addr =machine__get_running_kernel_start (machine, &name); +if (!addr) { + }else if (maps__set_kallsyms_ref_reloc_sym (machine->vmlinux_maps, name, addr)) {machine__destroy_kernel_maps (machine);return -1 ; }
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 3/11 perf trace: Warn when trying to resolve kernel addresses with kptr_restrict=1
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Hook into the libtraceevent plugin kernel symbol resolver to warn the user that that can't happen with kptr_restrict=1.
--- tools/perf/builtin-trace.c | 20 +++++++++++++++++++- tools/perf/util/machine.c | 1 + tools/perf/util/machine.h | 1 + 3 files changed, 21 insertions(+), 1 deletion(-)
tools/perf/builtin-trace.c +19 -1
@@ -1160,6 +1160,24 @@ static int trace__tool_process(struct perf_tool *tool,return trace__process_event (trace, machine, event, sample); } +static char *trace__machine__resolve_kernel_addr (void *vmachine,unsigned long long *addrp,char **modp) +{ +struct machine *machine = vmachine; + +if (machine->kptr_restrict_warned) +return NULL ; + +if (symbol_conf.kptr_restrict) { +pr_warning ("Kernel address maps (/proc/{kallsyms,modules}) are restricted.\n\n" +"Check /proc/sys/kernel/kptr_restrict.\n\n" +"Kernel samples will not be resolved.\n" ); + machine->kptr_restrict_warned = true; +return NULL ; + } + +return machine__resolve_kernel_addr (vmachine, addrp, modp); +} +static int trace__symbols_init (struct trace *trace,struct perf_evlist *evlist) {int err =symbol__init (NULL );
@@ -1171,7 +1189,7 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)if (trace->host ==NULL )return -ENOMEM ; -if (trace_event__register_resolver (trace->host, machine__resolve_kernel_addr) <0 ) +if (trace_event__register_resolver (trace->host, trace__machine__resolve_kernel_addr) <0 )return -errno; err = __machine__synthesize_threads(trace->host, &trace->tool, &trace->opts.target,
tools/perf/util/machine.c +1 -0
@@ -43,6 +43,7 @@ int machine__init(struct machine *machine, const char *root_dir, pid_t pid) machine->symbol_filter =NULL ; machine->id_hdr_size =0 ; + machine->kptr_restrict_warned = false; machine->comm_exec = false; machine->kernel_start =0 ;
tools/perf/util/machine.h +1 -0
@@ -28,6 +28,7 @@ struct machine {pid_t pid;u16 id_hdr_size;bool comm_exec; +bool kptr_restrict_warned;char *root_dir;struct rb_root threads;pthread_rwlock_t threads_lock;
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 4/11 perf top: Use machine->kptr_restrict_warned
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
Its now there, no need to have it too.
--- tools/perf/builtin-top.c | 6 +++--- tools/perf/util/top.h | 1 - 2 files changed, 3 insertions(+), 4 deletions(-)
tools/perf/builtin-top.c +3 -3
@@ -732,7 +732,7 @@ static void perf_event__process_sample(struct perf_tool *tool,if (machine__resolve (machine, &al, sample) <0 )return ; -if (!top->kptr_restrict_warned && +if (!machine->kptr_restrict_warned && symbol_conf.kptr_restrict && al.cpumode ==PERF_RECORD_MISC_KERNEL ) { ui__warning(
@@ -743,7 +743,7 @@ static void perf_event__process_sample(struct perf_tool *tool, " modules" : "");if (use_browser <=0 )sleep (5 ); - top->kptr_restrict_warned = true; + machine->kptr_restrict_warned = true; }if (al.sym ==NULL ) {
@@ -759,7 +759,7 @@ static void perf_event__process_sample(struct perf_tool *tool,* --hide-kernel-symbols, even if the user specifies an * invalid --vmlinux ;-) */ -if (!top->kptr_restrict_warned && !top->vmlinux_warned && +if (!machine->kptr_restrict_warned && !top->vmlinux_warned && al.map == machine->vmlinux_maps[MAP__FUNCTION ] &&RB_EMPTY_ROOT (&al.map->dso->symbols[MAP__FUNCTION ])) {if (symbol_conf.vmlinux_name) {
tools/perf/util/top.h +0 -1
@@ -27,7 +27,6 @@ struct perf_top {int max_stack;bool hide_kernel_symbols, hide_user_symbols, zero;bool use_tui, use_stdio; -bool kptr_restrict_warned;bool vmlinux_warned;bool dump_symtab;struct hist_entry *sym_filter_entry;
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 5/11 perf trace: Fix exit_group() formatting
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
This doesn't return, so there is no raw_syscalls:sys_exit for it, add the ending ')', without any return value, since it is void.
--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
@@ -1552,7 +1552,7 @@ static int trace__sys_enter(struct trace *trace, struct perf_evsel *evsel,if (sc->is_exit) {if (!(trace->duration_filter || trace->summary_only || trace->min_stack)) {trace__fprintf_entry_head (trace, thread,1 , sample->time, trace->output); -fprintf (trace->output,"%-70s\n" , ttrace->entry_str); +fprintf (trace->output,"%-70s)\n" , ttrace->entry_str); } }else { ttrace->entry_pending = true;
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 6/11 perf callchain: Stop validating callchains by the max_stack sysctl
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
As thread__resolve_callchain_sample can be used for handling perf.data files, that could've been recorded with a large max_stack sysctl setting than what the system used for analysis has set.
--- tools/perf/util/machine.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-)
tools/perf/util/machine.c +5 -20
@@ -1771,11 +1771,6 @@ static int resolve_lbr_callchain_sample(struct thread *thread,*/ int mix_chain_nr = i +1 + lbr_nr +1 ; -if (mix_chain_nr > (int )sysctl_perf_event_max_stack +PERF_MAX_BRANCH_DEPTH ) { -pr_warning ("corrupted callchain. skipping...\n" ); -return 0 ; - } -for (j =0 ; j < mix_chain_nr; j++) {if (callchain_param.order ==ORDER_CALLEE ) {if (j < i +1 )
@@ -1815,7 +1810,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,struct ip_callchain *chain = sample->callchain;int chain_nr = chain->nr;u8 cpumode =PERF_RECORD_MISC_USER ; -int i, j, err, nr_entries, nr_contexts; +int i, j, err, nr_entries;int skip_idx =-1 ;int first_call =0 ;
@@ -1830,8 +1825,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,* Based on DWARF debug information, some architectures skip * a callchain entry saved by the kernel. */ -if (chain_nr < sysctl_perf_event_max_stack) - skip_idx =arch_skip_callchain_idx (thread, chain); + skip_idx =arch_skip_callchain_idx (thread, chain);/* * Add branches to call stack for easier browsing. This gives
@@ -1891,7 +1885,7 @@ static int thread__resolve_callchain_sample(struct thread *thread, } check_calls: -for (i = first_call, nr_entries =0 , nr_contexts =0 ; +for (i = first_call, nr_entries =0 ; i < chain_nr && nr_entries < max_stack; i++) {u64 ip;
@@ -1906,13 +1900,8 @@ check_calls:#endif ip = chain->ips[j]; -if (ip >=PERF_CONTEXT_MAX ) { -if (++nr_contexts > sysctl_perf_event_max_contexts_per_stack) - goto out_corrupted_callchain; - }else { -if (++nr_entries > sysctl_perf_event_max_stack) - goto out_corrupted_callchain; - } +if (ip <PERF_CONTEXT_MAX ) + ++nr_entries; err =add_callchain_ip (thread, cursor, parent, root_al, &cpumode, ip);
@@ -1921,10 +1910,6 @@ check_calls: }return 0 ; - -out_corrupted_callchain: -pr_warning ("corrupted callchain. skipping...\n" ); -return 0 ; }static int unwind_entry (struct unwind_entry *entry,void *arg)
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 7/11 perf tools: Fix usage of max_stack sysctl
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
We cannot limit processing stacks from the current value of the sysctl, as we may be processing perf.data files, possibly from other machines.
Instead use the old PERF_MAX_STACK_DEPTH, the sysctl default, that can be overriden using --max-stack or equivalent.
--- tools/perf/Documentation/perf-report.txt | 2 +- tools/perf/Documentation/perf-script.txt | 2 +- tools/perf/Documentation/perf-trace.txt | 3 ++- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-script.c | 2 -- tools/perf/builtin-trace.c | 2 +- tools/perf/util/db-export.c | 3 +-- tools/perf/util/scripting-engines/trace-event-perl.c | 3 +-- 8 files changed, 8 insertions(+), 11 deletions(-)
tools/perf/Documentation/perf-report.txt +1 -1
@@ -248,7 +248,7 @@ OPTIONS Note that when using the --itrace option the synthesized callchain size will override this value if the synthesized callchain size is bigger. - Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise. + Default: 127 -G:: --inverted::
tools/perf/Documentation/perf-script.txt +1 -1
@@ -267,7 +267,7 @@ include::itrace.txt[] Note that when using the --itrace option the synthesized callchain size will override this value if the synthesized callchain size is bigger. - Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise. + Default: 127 --ns:: Use 9 decimal places when displaying time (i.e. show the nanoseconds)
tools/perf/Documentation/perf-trace.txt +2 -1
@@ -143,7 +143,8 @@ the thread executes on the designated CPUs. Default is to monitor all CPUs. Implies '--call-graph dwarf' when --call-graph not present on the command line, on systems where DWARF unwinding was built in. - Default: /proc/sys/kernel/perf_event_max_stack when present, 127 otherwise. + Default: /proc/sys/kernel/perf_event_max_stack when present for + live sessions (without --input/-i), 127 otherwise. --min-stack:: Set the stack depth limit when parsing the callchain, anything
tools/perf/builtin-report.c +1 -1
@@ -691,7 +691,7 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) .ordered_events = true, .ordering_requires_timestamps = true, }, - .max_stack = sysctl_perf_event_max_stack, + .max_stack = PERF_MAX_STACK_DEPTH, .pretty_printing_style = "normal", .socket_filter = -1, };
tools/perf/builtin-script.c +0 -2
@@ -2067,8 +2067,6 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)NULL }; - scripting_max_stack = sysctl_perf_event_max_stack; -setup_scripting (); argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,
tools/perf/builtin-trace.c +1 -1
@@ -2905,7 +2905,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) mmap_pages_user_set = false;if (trace.max_stack ==UINT_MAX ) { - trace.max_stack = sysctl_perf_event_max_stack; + trace.max_stack = input_name ?PERF_MAX_STACK_DEPTH : sysctl_perf_event_max_stack; max_stack_user_set = false; }
tools/perf/util/db-export.c +1 -2
@@ -298,8 +298,7 @@ static struct call_path *call_path_from_sample(struct db_export *dbe,*/ callchain_param.order =ORDER_CALLER ; err =thread__resolve_callchain (thread, &callchain_cursor, evsel, - sample,NULL ,NULL , - sysctl_perf_event_max_stack); + sample,NULL ,NULL ,PERF_MAX_STACK_DEPTH );if (err) { callchain_param.order = saved_order;return NULL ;
tools/perf/util/scripting-engines/trace-event-perl.c +1 -2
@@ -264,8 +264,7 @@ static SV *perl_process_callchain(struct perf_sample *sample, goto exit;if (thread__resolve_callchain (al->thread, &callchain_cursor, evsel, - sample,NULL ,NULL , - sysctl_perf_event_max_stack) !=0 ) { + sample,NULL ,NULL , scripting_max_stack) !=0 ) {pr_err ("Failed to resolve callchain. Skipping\n" ); goto exit; }
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 8/11 perf annotate: Fix identification of ARM blt and bls instructions
In reply to Arnaldo Carvalho de MeloFrom: Chris Ryder <[email protected]>
The ARM blt and bls instructions are not correctly identified when parsing assembly because the list of recognised instructions must be sorted by name. Swap the ordering of blt and bls.
--- tools/perf/util/annotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/annotate.c +1 -1
@@ -372,8 +372,8 @@ static struct ins instructions[] = { { .name = "bgt", .ops = &jump_ops, }, { .name = "bhi", .ops = &jump_ops, }, { .name = "bl", .ops = &call_ops, }, - { .name = "blt", .ops = &jump_ops, }, { .name = "bls", .ops = &jump_ops, }, + { .name = "blt", .ops = &jump_ops, }, { .name = "blx", .ops = &call_ops, }, { .name = "bne", .ops = &jump_ops, }, #endif
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 9/11 perf annotate: Sort list of recognised instructions
In reply to Arnaldo Carvalho de MeloFrom: Chris Ryder <[email protected]>
Currently the list of instructions recognised by perf annotate has to be explicitly written in sorted order. This makes it easy to make mistakes when adding new instructions. Sort the list of instructions on first access.
--- tools/perf/util/annotate.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-)
tools/perf/util/annotate.c +23 -5
@@ -354,9 +354,6 @@ static struct ins_ops nop_ops = { .scnprintf = nop__scnprintf, }; -/* -* Must be sorted by name! -*/ static struct ins instructions[] = { { .name ="add" , .ops = &mov_ops, }, { .name ="addl" , .ops = &mov_ops, },
@@ -449,18 +446,39 @@ static struct ins instructions[] = { { .name = "xbeginq", .ops = &jump_ops, }, }; -static int ins__cmp (const void *name,const void *insp) +static int ins__key_cmp (const void *name,const void *insp) {const struct ins *ins = insp;return strcmp (name, ins->name); } +static int ins__cmp (const void *a,const void *b) +{ +const struct ins *ia = a; +const struct ins *ib = b; + +return strcmp (ia->name, ib->name); +} + +static void ins__sort (void ) +{ +const int nmemb =ARRAY_SIZE (instructions); + +qsort (instructions, nmemb,sizeof (struct ins ), ins__cmp); +} +static struct ins *ins__find (const char *name) {const int nmemb =ARRAY_SIZE (instructions); +static bool sorted; + +if (!sorted) { +ins__sort (); + sorted = true; + } -return bsearch (name, instructions, nmemb,sizeof (struct ins ), ins__cmp); +return bsearch (name, instructions, nmemb,sizeof (struct ins ), ins__key_cmp); }int symbol__annotate_init (struct map *map__maybe_unused ,struct symbol *sym)
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 10/11 perf trace: Only auto set call-graph to "dwarf" when syscalls are being traced
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
When --min-stack or --max-stack is passwd but --no-syscalls is also in effect, there is no point in automatically setting '--call-graph dwarf'.
--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
@@ -2910,7 +2910,7 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) }#ifdef HAVE_DWARF_UNWIND_SUPPORT -if ((trace.min_stack || max_stack_user_set) && !callchain_param.enabled) +if ((trace.min_stack || max_stack_user_set) && !callchain_param.enabled && trace.trace_syscalls)record_opts__parse_callchain (&trace.opts, &callchain_param,"dwarf" , false);#endif
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerPATCH 11/11 perf tools: Set buildid dir under symfs when --symfs is provided
In reply to Arnaldo Carvalho de MeloFrom: He Kuang <[email protected]>
This patch moves the reference of buildid dir to 'symfs/.debug' and skips the local buildid dir when '--symfs' is given, so that every single file opened by perf is relative to symfs directory now.
--- tools/perf/builtin-annotate.c | 5 +++-- tools/perf/builtin-diff.c | 5 +++-- tools/perf/builtin-report.c | 5 +++-- tools/perf/builtin-script.c | 5 +++-- tools/perf/builtin-timechart.c | 5 +++-- tools/perf/util/dso.c | 4 +--- tools/perf/util/symbol.c | 23 +++++++++++++++++++++++ tools/perf/util/symbol.h | 2 ++ 8 files changed, 41 insertions(+), 13 deletions(-)
tools/perf/builtin-annotate.c +3 -2
@@ -324,8 +324,9 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)OPT_BOOLEAN (0 ,"skip-missing" , &annotate.skip_missing,"Skip symbols that cannot be annotated" ),OPT_STRING ('C' ,"cpu" , &annotate.cpu_list,"cpu" ,"list of cpus to profile" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_BOOLEAN (0 ,"source" , &symbol_conf.annotate_src,"Interleave source code with assembly code (default)" ), OPT_BOOLEAN(0, "asm-raw", &symbol_conf.annotate_asm_raw,
tools/perf/builtin-diff.c +3 -2
@@ -812,8 +812,9 @@ static const struct option options[] = {OPT_STRING_NOEMPTY ('t' ,"field-separator" , &symbol_conf.field_sep,"separator" ,"separator for columns, no spaces will be added between " "columns '.' is reserved." ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_UINTEGER ('o' ,"order" , &sort_compute,"Specify compute sorting." ),OPT_CALLBACK (0 ,"percentage" ,NULL ,"relative|absolute" , "How to display percentage of filtered entries", parse_filter_percentage),
tools/perf/builtin-report.c +3 -2
@@ -770,8 +770,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused) "columns '.' is reserved."),OPT_BOOLEAN ('U' ,"hide-unresolved" , &symbol_conf.hide_unresolved,"Only display entries resolved to a symbol" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_STRING ('C' ,"cpu" , &report.cpu_list,"cpu" ,"list of cpus to profile" ), OPT_BOOLEAN('I', "show-info", &report.show_full_info,
tools/perf/builtin-script.c +3 -2
@@ -2010,8 +2010,9 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused) "file", "kallsyms pathname"),OPT_BOOLEAN ('G' ,"hide-call-graph" , &no_callchain,"When printing symbols do not display call chain" ), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_CALLBACK ('F' ,"fields" ,NULL ,"str" ,"comma separated output fields prepend with 'type:'. " "Valid types: hw,sw,trace,raw. "
tools/perf/builtin-timechart.c +3 -2
@@ -1945,8 +1945,9 @@ int cmd_timechart(int argc, const char **argv,OPT_CALLBACK ('p' ,"process" ,NULL ,"process" ,"process selector. Pass a pid or process name." , parse_process), -OPT_STRING (0 ,"symfs" , &symbol_conf.symfs,"directory" , -"Look for files with symbols relative to this directory" ), +OPT_CALLBACK (0 ,"symfs" ,NULL ,"directory" , +"Look for files with symbols relative to this directory" , + symbol__config_symfs),OPT_INTEGER ('n' ,"proc-num" , &tchart.proc_num,"min. number of tasks to print" ), OPT_BOOLEAN('t', "topology", &tchart.topology,
tools/perf/util/dso.c +1 -3
@@ -63,9 +63,7 @@ int dso__read_binary_type_filename(const struct dso *dso, }break ;case DSO_BINARY_TYPE__BUILD_ID_CACHE : -/* skip the locally configured cache if a symfs is given */ -if (symbol_conf.symfs[0 ] || - (dso__build_id_filename (dso, filename, size) ==NULL )) +if (dso__build_id_filename (dso, filename, size) ==NULL ) ret =-1 ;break ;
tools/perf/util/symbol.c +23 -0
@@ -2033,3 +2033,26 @@ void symbol__exit(void) symbol_conf.sym_list = symbol_conf.dso_list = symbol_conf.comm_list =NULL ; symbol_conf.initialized = false; } + +int symbol__config_symfs (const struct option *opt__maybe_unused , +const char *dir,int unset__maybe_unused ) +{ +char *bf =NULL ; +int ret; + + symbol_conf.symfs =strdup (dir); +if (symbol_conf.symfs ==NULL ) +return -ENOMEM ; + +/* skip the locally configured cache if a symfs is given, and +* config buildid dir to symfs/.debug +*/ + ret =asprintf (&bf,"%s/%s" , dir,".debug" ); +if (ret <0 ) +return -ENOMEM ; + +set_buildid_dir (bf); + +free (bf); +return 0 ; +}
tools/perf/util/symbol.h +2 -0
@@ -290,6 +290,8 @@ bool symbol_type__is_a(char symbol_type, enum map_type map_type);bool symbol__restricted_filename (const char *filename,const char *restricted_filename);bool symbol__is_idle (struct symbol *sym); +int symbol__config_symfs (const struct option *opt__maybe_unused , +const char *dir,int unset__maybe_unused ); int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, struct symsrc *runtime_ss, symbol_filter_t filter,
Signature · 1 line
2.5.5
Arnaldo Carvalho de Melo
maintainerEm Thu, May 19, 2016 at 07:21:22PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 4 lines
Hi Ingo,
Please consider pulling, this is on top of my previous pull
request (perf-core-for-mingo-20160516).
So, here is a new pull req, removing the following patch, due to that segfault you noticed while testing 'perf top' on an ubuntu system:
Quoted 2 lines
He Kuang (2):
perf tools: Find vdso supporting cross-platform analysis
The new tag is perf-core-for-mingo-20160520.
Kuang, Ingo proposed the patch below to fix the problem he noticed (notice the 'dso && ' part, as __dsos__find() may return NULL), but he had several other issues with code touched by this patch, I'll try to address those, please check the patch below and resubmit.
- Arnaldo
tools/perf/util/vdso.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
tools/perf/util/vdso.c +6 -6
@@ -293,12 +293,12 @@ static struct dso *machine__find_vdso(struct machine *machine,switch (dso_type) {case DSO__TYPE_32BIT : dso =__dsos__find (&machine->dsos,DSO__NAME_VDSO32 , true); -if (!dso) { - dso =__dsos__find (&machine->dsos,DSO__NAME_VDSO , - true); -if (dso_type !=dso__type (dso, machine)) - dso =NULL ; - } +if (dso) +break ; + + dso =__dsos__find (&machine->dsos,DSO__NAME_VDSO , true); +if (dso && dso_type !=dso__type (dso, machine)) + dso =NULL ;break ;case DSO__TYPE_X32BIT : dso =__dsos__find (&machine->dsos,DSO__NAME_VDSOX32 , true);
Quoted 7 lines · Arnaldo Carvalho de Melo
Em Thu, May 19, 2016 at 07:21:22PM -0300, Arnaldo Carvalho de Melo escreveu:
Quoted 4 lines
Hi Ingo,
Please consider pulling, this is on top of my previous pull
request (perf-core-for-mingo-20160516).The new tag is perf-core-for-mingo-20160520.
Pulled, thanks a lot Arnaldo!
Ingo