Skip to content

Commit c0b172e

Browse files
author
Ingo Molnar
committed
Merge tag 'perf-core-for-mingo-20160901' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: User visible changes: - Support generating cross arch probes, i.e. if you specify a vmlinux file for different arch than the one in the host machine, $ perf probe --definition function_name args will generate the probe definition string needed to append to the target machine /sys/kernel/debug/tracing/kprobes_events file, using scripting (Masami Hiramatsu). - Make 'perf probe' skip the function prologue in uprobes if program compiled without optimization, using the same strategy as gdb and systemtap uses, fixing a bug where: $ perf probe -x ./test 'foo i' When 'foo(42)' was used on the "./test" executable would produce i=0 instead of the expected i=42 (Ravi Bangoria) - Demangle symbols for synthesized @plt entries too (Millian Wolff) Documentation changes: - Show default report configuration in 'perf config' example and docs (Millian Wolff) Infrastructure changes: - Make 'perf test vmlinux' tolerate the symbol aliasing pruning done when loading kallsyms and vmlinux (Arnaldo Carvalho de Melo) - Improve output of 'perf test vmlinux' test, to help identify on the verbose output which lines are warning and which are errors (Arnaldo Carvalho de Melo) - Prep work to stop having to pass symbol_filter_t to lots of functions, simplifying symtab loading routines (Arnaldo Carvalho de Melo) - Honor symbol_conf.allow_aliases when loading kallsyms as well, it was using it only when loading vmlinux files (Arnaldo Carvalho de Melo) - Fixup symbol->end before doing alias pruning when loading symbol tables (Arnaldo Carvalho de Melo) - Fix error handling of lzma kernel module decompression (Shawn Lin) Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
2 parents c9bbdd4 + 6243b9d commit c0b172e

33 files changed

+698
-121
lines changed

tools/perf/Documentation/perf-config.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ Given a $HOME/.perfconfig like this:
110110
order = caller
111111
sort-key = function
112112

113+
[report]
114+
# Defaults
115+
sort-order = comm,dso,symbol
116+
percent-limit = 0
117+
queue-size = 0
118+
children = true
119+
group = true
120+
113121
Variables
114122
~~~~~~~~~
115123

tools/perf/Documentation/perf-probe.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ or
2121
'perf probe' [options] --vars='PROBEPOINT'
2222
or
2323
'perf probe' [options] --funcs
24+
or
25+
'perf probe' [options] --definition='PROBE' [...]
2426

2527
DESCRIPTION
2628
-----------
@@ -34,6 +36,8 @@ OPTIONS
3436
-k::
3537
--vmlinux=PATH::
3638
Specify vmlinux path which has debuginfo (Dwarf binary).
39+
Only when using this with --definition, you can give an offline
40+
vmlinux file.
3741

3842
-m::
3943
--module=MODNAME|PATH::
@@ -96,6 +100,11 @@ OPTIONS
96100
can also list functions in a user space executable / shared library.
97101
This also can accept a FILTER rule argument.
98102

103+
-D::
104+
--definition=::
105+
Show trace-event definition converted from given probe-event instead
106+
of write it into tracing/[k,u]probe_events.
107+
99108
--filter=FILTER::
100109
(Only for --vars and --funcs) Set filter. FILTER is a combination of glob
101110
pattern, see FILTER PATTERN for detail.

tools/perf/Documentation/perfconfig.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@
2727
use_offset = true
2828
jump_arrows = true
2929
show_nr_jumps = false
30+
31+
[report]
32+
33+
# Defaults
34+
sort-order = comm,dso,symbol
35+
percent-limit = 0
36+
queue-size = 0
37+
children = true
38+
group = true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
static const char * const arm_regstr_tbl[] = {
5+
"%r0", "%r1", "%r2", "%r3", "%r4",
6+
"%r5", "%r6", "%r7", "%r8", "%r9", "%r10",
7+
"%fp", "%ip", "%sp", "%lr", "%pc",
8+
};
9+
#endif
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
static const char * const aarch64_regstr_tbl[] = {
5+
"%r0", "%r1", "%r2", "%r3", "%r4",
6+
"%r5", "%r6", "%r7", "%r8", "%r9",
7+
"%r10", "%r11", "%r12", "%r13", "%r14",
8+
"%r15", "%r16", "%r17", "%r18", "%r19",
9+
"%r20", "%r21", "%r22", "%r23", "%r24",
10+
"%r25", "%r26", "%r27", "%r28", "%r29",
11+
"%lr", "%sp",
12+
};
13+
#endif
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
/*
5+
* Reference:
6+
* http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html
7+
* http://refspecs.linux-foundation.org/elf/elfspec_ppc.pdf
8+
*/
9+
#define REG_DWARFNUM_NAME(reg, idx) [idx] = "%" #reg
10+
11+
static const char * const powerpc_regstr_tbl[] = {
12+
"%gpr0", "%gpr1", "%gpr2", "%gpr3", "%gpr4",
13+
"%gpr5", "%gpr6", "%gpr7", "%gpr8", "%gpr9",
14+
"%gpr10", "%gpr11", "%gpr12", "%gpr13", "%gpr14",
15+
"%gpr15", "%gpr16", "%gpr17", "%gpr18", "%gpr19",
16+
"%gpr20", "%gpr21", "%gpr22", "%gpr23", "%gpr24",
17+
"%gpr25", "%gpr26", "%gpr27", "%gpr28", "%gpr29",
18+
"%gpr30", "%gpr31",
19+
REG_DWARFNUM_NAME(msr, 66),
20+
REG_DWARFNUM_NAME(ctr, 109),
21+
REG_DWARFNUM_NAME(link, 108),
22+
REG_DWARFNUM_NAME(xer, 101),
23+
REG_DWARFNUM_NAME(dar, 119),
24+
REG_DWARFNUM_NAME(dsisr, 118),
25+
};
26+
27+
#endif
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
static const char * const s390_regstr_tbl[] = {
5+
"%r0", "%r1", "%r2", "%r3", "%r4", "%r5", "%r6", "%r7",
6+
"%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15",
7+
};
8+
#endif
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
const char * const sh_regstr_tbl[] = {
5+
"r0",
6+
"r1",
7+
"r2",
8+
"r3",
9+
"r4",
10+
"r5",
11+
"r6",
12+
"r7",
13+
"r8",
14+
"r9",
15+
"r10",
16+
"r11",
17+
"r12",
18+
"r13",
19+
"r14",
20+
"r15",
21+
"pc",
22+
"pr",
23+
};
24+
25+
#endif
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
static const char * const sparc_regstr_tbl[] = {
5+
"%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7",
6+
"%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%sp", "%o7",
7+
"%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7",
8+
"%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%fp", "%i7",
9+
"%f0", "%f1", "%f2", "%f3", "%f4", "%f5", "%f6", "%f7",
10+
"%f8", "%f9", "%f10", "%f11", "%f12", "%f13", "%f14", "%f15",
11+
"%f16", "%f17", "%f18", "%f19", "%f20", "%f21", "%f22", "%f23",
12+
"%f24", "%f25", "%f26", "%f27", "%f28", "%f29", "%f30", "%f31",
13+
"%f32", "%f33", "%f34", "%f35", "%f36", "%f37", "%f38", "%f39",
14+
"%f40", "%f41", "%f42", "%f43", "%f44", "%f45", "%f46", "%f47",
15+
"%f48", "%f49", "%f50", "%f51", "%f52", "%f53", "%f54", "%f55",
16+
"%f56", "%f57", "%f58", "%f59", "%f60", "%f61", "%f62", "%f63",
17+
};
18+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
static const char * const x86_32_regstr_tbl[] = {
5+
"%ax", "%cx", "%dx", "%bx", "$stack",/* Stack address instead of %sp */
6+
"%bp", "%si", "%di",
7+
};
8+
9+
static const char * const x86_64_regstr_tbl[] = {
10+
"%ax", "dx", "%cx", "%bx", "%si", "%di",
11+
"%bp", "%sp", "%r8", "%r9", "%r10", "%r11",
12+
"%r12", "%r13", "%r14", "%r15",
13+
};
14+
#endif
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifdef DEFINE_DWARF_REGSTR_TABLE
2+
/* This is included in perf/util/dwarf-regs.c */
3+
4+
static const char * const xtensa_regstr_tbl[] = {
5+
"a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
6+
"a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
7+
};
8+
#endif

tools/perf/builtin-annotate.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ static int __cmd_annotate(struct perf_annotate *ann)
204204
struct perf_evsel *pos;
205205
u64 total_nr_samples;
206206

207-
machines__set_symbol_filter(&session->machines, symbol__annotate_init);
208-
209207
if (ann->cpu_list) {
210208
ret = perf_session__cpu_bitmap(session, ann->cpu_list,
211209
ann->cpu_bitmap);
@@ -367,7 +365,10 @@ int cmd_annotate(int argc, const char **argv, const char *prefix __maybe_unused)
367365
if (annotate.session == NULL)
368366
return -1;
369367

370-
symbol_conf.priv_size = sizeof(struct annotation);
368+
ret = symbol__annotation_init();
369+
if (ret < 0)
370+
goto out_delete;
371+
371372
symbol_conf.try_vmlinux_path = true;
372373

373374
ret = symbol__init(&annotate.session->header.env);

tools/perf/builtin-probe.c

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ static int perf_add_probe_events(struct perf_probe_event *pevs, int npevs)
326326
if (ret < 0)
327327
goto out_cleanup;
328328

329+
if (params.command == 'D') { /* it shows definition */
330+
ret = show_probe_trace_events(pevs, npevs);
331+
goto out_cleanup;
332+
}
333+
329334
ret = apply_perf_probe_events(pevs, npevs);
330335
if (ret < 0)
331336
goto out_cleanup;
@@ -454,6 +459,14 @@ static int perf_del_probe_events(struct strfilter *filter)
454459
return ret;
455460
}
456461

462+
#ifdef HAVE_DWARF_SUPPORT
463+
#define PROBEDEF_STR \
464+
"[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT [[NAME=]ARG ...]"
465+
#else
466+
#define PROBEDEF_STR "[EVENT=]FUNC[+OFF|%return] [[NAME=]ARG ...]"
467+
#endif
468+
469+
457470
static int
458471
__cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
459472
{
@@ -479,13 +492,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
479492
opt_set_filter_with_command, DEFAULT_LIST_FILTER),
480493
OPT_CALLBACK('d', "del", NULL, "[GROUP:]EVENT", "delete a probe event.",
481494
opt_set_filter_with_command),
482-
OPT_CALLBACK('a', "add", NULL,
483-
#ifdef HAVE_DWARF_SUPPORT
484-
"[EVENT=]FUNC[@SRC][+OFF|%return|:RL|;PT]|SRC:AL|SRC;PT"
485-
" [[NAME=]ARG ...]",
486-
#else
487-
"[EVENT=]FUNC[+OFF|%return] [[NAME=]ARG ...]",
488-
#endif
495+
OPT_CALLBACK('a', "add", NULL, PROBEDEF_STR,
489496
"probe point definition, where\n"
490497
"\t\tGROUP:\tGroup name (optional)\n"
491498
"\t\tEVENT:\tEvent name\n"
@@ -503,6 +510,9 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
503510
"\t\tARG:\tProbe argument (kprobe-tracer argument format.)\n",
504511
#endif
505512
opt_add_probe_event),
513+
OPT_CALLBACK('D', "definition", NULL, PROBEDEF_STR,
514+
"Show trace event definition of given traceevent for k/uprobe_events.",
515+
opt_add_probe_event),
506516
OPT_BOOLEAN('f', "force", &probe_conf.force_add, "forcibly add events"
507517
" with existing name"),
508518
OPT_CALLBACK('L', "line", NULL,
@@ -548,6 +558,7 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
548558

549559
set_option_flag(options, 'a', "add", PARSE_OPT_EXCLUSIVE);
550560
set_option_flag(options, 'd', "del", PARSE_OPT_EXCLUSIVE);
561+
set_option_flag(options, 'D', "definition", PARSE_OPT_EXCLUSIVE);
551562
set_option_flag(options, 'l', "list", PARSE_OPT_EXCLUSIVE);
552563
#ifdef HAVE_DWARF_SUPPORT
553564
set_option_flag(options, 'L', "line", PARSE_OPT_EXCLUSIVE);
@@ -600,6 +611,14 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
600611
*/
601612
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
602613

614+
/*
615+
* Except for --list, --del and --add, other command doesn't depend
616+
* nor change running kernel. So if user gives offline vmlinux,
617+
* ignore its buildid.
618+
*/
619+
if (!strchr("lda", params.command) && symbol_conf.vmlinux_name)
620+
symbol_conf.ignore_vmlinux_buildid = true;
621+
603622
switch (params.command) {
604623
case 'l':
605624
if (params.uprobes) {
@@ -643,7 +662,9 @@ __cmd_probe(int argc, const char **argv, const char *prefix __maybe_unused)
643662
return ret;
644663
}
645664
break;
665+
case 'D':
646666
case 'a':
667+
647668
/* Ensure the last given target is used */
648669
if (params.target && !params.target_used) {
649670
pr_err(" Error: -x/-m must follow the probe definitions.\n");

tools/perf/builtin-report.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,9 @@ int cmd_report(int argc, const char **argv, const char *prefix __maybe_unused)
984984
* implementation.
985985
*/
986986
if (ui__has_annotation()) {
987-
symbol_conf.priv_size = sizeof(struct annotation);
988-
machines__set_symbol_filter(&session->machines,
989-
symbol__annotate_init);
987+
ret = symbol__annotation_init();
988+
if (ret < 0)
989+
goto error;
990990
/*
991991
* For searching by name on the "Browse map details".
992992
* providing it only in verbose mode not to bloat too

tools/perf/builtin-top.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ static int symbol_filter(struct map *map, struct symbol *sym)
680680
return 1;
681681

682682
if (symbol__is_idle(sym))
683-
sym->ignore = true;
683+
sym->idle = 1;
684684

685685
return 0;
686686
}
@@ -783,7 +783,7 @@ static void perf_event__process_sample(struct perf_tool *tool,
783783
}
784784
}
785785

786-
if (al.sym == NULL || !al.sym->ignore) {
786+
if (al.sym == NULL || !al.sym->idle) {
787787
struct hists *hists = evsel__hists(evsel);
788788
struct hist_entry_iter iter = {
789789
.evsel = evsel,
@@ -1324,7 +1324,9 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
13241324
if (symbol_conf.cumulate_callchain && !callchain_param.order_set)
13251325
callchain_param.order = ORDER_CALLER;
13261326

1327-
symbol_conf.priv_size = sizeof(struct annotation);
1327+
status = symbol__annotation_init();
1328+
if (status < 0)
1329+
goto out_delete_evlist;
13281330

13291331
symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
13301332
if (symbol__init(NULL) < 0)

0 commit comments

Comments
 (0)