perf annotate: Allow showing offsets in more than just jump targets
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 592c10e217f3edb35c7e0deba161fef69ad1a336 Gitweb: https://git.kernel.org/tip/592c10e217f3edb35c7e0deba161fef69ad1a336 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Wed, 11 Apr 2018 10:30:03 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Thu, 12 Apr 2018 10:32:39 -0300
perf annotate: Allow showing offsets in more than just jump targets
Jesper wanted to see offsets at callq sites when doing some performance investigation related to retpolines, so save him some time by providing an 'struct annotation_options' to control where offsets should appear:
just on jump targets? That + call instructions? All?
This puts in place the logic to show the offsets, now we need to wire this up in the TUI browser (next patch) and on the 'perf annotate --stdio2" interface, where we need a more general mechanism to setup the 'annotation_options' struct from the command line.
Suggested-by Jesper Dangaard Brouer <[email protected]>
Cc Adrian Hunter <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Andi Kleen <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc David Ahern <[email protected]>
Cc Jin Yao <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Martin Liška <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Ravi Bangoria <[email protected]>
Cc Thomas Richter <[email protected]>
Cc Wang Nan <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/util/annotate.c | 11 +++++++++-- tools/perf/util/annotate.h | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-)
tools/perf/util/annotate.c +9 -2
@@ -46,6 +46,7 @@struct annotation_options annotation__default_options = { .use_offset = true, .jump_arrows = true, + .offset_level =ANNOTATION__OFFSET_JUMP_TARGETS , };const char *disassembler_style;
@@ -2512,7 +2513,8 @@ static void __annotation_line__write(struct annotation_line *al, struct annotatiif (!notes->options->use_offset) { printed =scnprintf (bf,sizeof (bf),"%" PRIx64": " , addr); }else { -if (al->jump_sources) { +if (al->jump_sources && + notes->options->offset_level >=ANNOTATION__OFFSET_JUMP_TARGETS ) {if (notes->options->show_nr_jumps) {int prev; printed = scnprintf(bf, sizeof(bf), "%*d ",
@@ -2523,9 +2525,14 @@ static void __annotation_line__write(struct annotation_line *al, struct annotatiobj__printf (obj, bf);obj__set_color (obj, prev); } - +print_addr: printed =scnprintf (bf,sizeof (bf),"%*" PRIx64": " , notes->widths.target, addr); + }else if (ins__is_call (&disasm_line (al)->ins) && + notes->options->offset_level >=ANNOTATION__OFFSET_CALL ) { + goto print_addr; + }else if (notes->options->offset_level ==ANNOTATION__MAX_OFFSET_LEVEL ) { + goto print_addr; }else { printed =scnprintf (bf,sizeof (bf),"%-*s " , notes->widths.addr," " );
tools/perf/util/annotate.h +9 -0
@@ -70,8 +70,17 @@ struct annotation_options { show_nr_jumps, show_nr_samples, show_total_period; +u8 offset_level; }; +enum { +ANNOTATION__OFFSET_JUMP_TARGETS =1 , +ANNOTATION__OFFSET_CALL , +ANNOTATION__MAX_OFFSET_LEVEL , +}; + +#define ANNOTATION__MIN_OFFSET_LEVEL ANNOTATION__OFFSET_JUMP_TARGETS +extern struct annotation_options annotation__default_options;struct annotation ;