[PATCH 05/17] perf annotate browser: Allow showing offsets in more than just jump targets

From: Arnaldo Carvalho de Melo
Date: Fri Apr 13 2018 - 10:01:52 EST


From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

Jesper wanted to see offsets at callq sites when doing some performance
investigation related to retpolines, so save him some time by providing
a 'O' hotkey to allow showing offsets from function start at call
instructions or in all instructions, just go on pressing 'O' till the
offsets you need appear.

Example:

Starts with:

Samples: 64 of event 'cycles:ppp', 100000 Hz, Event count (approx.): 318963
ixgbe_read_reg /proc/kcore
Percentâ â je 2a
â âââcmp $0xffffffff,%r13d
â âââje d0
â â mov $0x53e3,%edi
â ââ callq __const_udelay
â â sub $0x1,%r15d
â ââ jne 83
â â mov 0x8(%rbp),%rax
â â testb $0x20,0x1799(%rax)
â ââ je 2a
â â mov 0x200(%rax),%rdi
â â mov %r13d,%edx
â â mov $0xffffffffc02595d8,%rsi
â ââ callq netdev_warn
â ââ jmpq 2a
âd0:âââmov 0x8(%rbp),%rsi
â mov %rbp,%rdi
â mov %eax,0x4(%rsp)
â â callq ixgbe_remove_adapter.isra.77
â mov 0x4(%rsp),%eax
Press 'h' for help on key bindings
============================================================================

Pess 'O':

Samples: 64 of event 'cycles:ppp', 100000 Hz, Event count (approx.): 318963
ixgbe_read_reg /proc/kcore
Percentâ â je 2a
â âââcmp $0xffffffff,%r13d
â âââje d0
â â mov $0x53e3,%edi
â99:ââ callq __const_udelay
â â sub $0x1,%r15d
â ââ jne 83
â â mov 0x8(%rbp),%rax
â â testb $0x20,0x1799(%rax)
â ââ je 2a
â â mov 0x200(%rax),%rdi
â â mov %r13d,%edx
â â mov $0xffffffffc02595d8,%rsi
âc6:ââ callq netdev_warn
â ââ jmpq 2a
âd0:âââmov 0x8(%rbp),%rsi
â mov %rbp,%rdi
â mov %eax,0x4(%rsp)
âdb: â callq ixgbe_remove_adapter.isra.77
â mov 0x4(%rsp),%eax
Press 'h' for help on key bindings
============================================================================

Press 'O' again:

Samples: 64 of event 'cycles:ppp', 100000 Hz, Event count (approx.): 318963
ixgbe_read_reg /proc/kcore
Percentâ8c: â je 2a
â8e:âââcmp $0xffffffff,%r13d
â92:âââje d0
â94:â mov $0x53e3,%edi
â99:ââ callq __const_udelay
â9e:â sub $0x1,%r15d
âa2:ââ jne 83
âa4:â mov 0x8(%rbp),%rax
âa8:â testb $0x20,0x1799(%rax)
âaf:ââ je 2a
âb5:â mov 0x200(%rax),%rdi
âbc:â mov %r13d,%edx
âbf:â mov $0xffffffffc02595d8,%rsi
âc6:ââ callq netdev_warn
âcb:ââ jmpq 2a
âd0:âââmov 0x8(%rbp),%rsi
âd4: mov %rbp,%rdi
âd7: mov %eax,0x4(%rsp)
âdb: â callq ixgbe_remove_adapter.isra.77
âe0: mov 0x4(%rsp),%eax
Press 'h' for help on key bindings
============================================================================

Press 'O' again and it will show just jump target offsets.

Suggested-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx>
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Alexei Starovoitov <alexei.starovoitov@xxxxxxxxx>
Cc: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
Cc: David Ahern <dsahern@xxxxxxxxx>
Cc: Jin Yao <yao.jin@xxxxxxxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Martin LiÅka <mliska@xxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Ravi Bangoria <ravi.bangoria@xxxxxxxxxxxxxxxxxx>
Cc: Thomas Richter <tmricht@xxxxxxxxxxxxxxxxxx>
Cc: Wang Nan <wangnan0@xxxxxxxxxx>
Link: https://lkml.kernel.org/n/tip-upp6pfdetwlsx18ec2uf1od4@xxxxxxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/ui/browsers/annotate.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 12c099a87f8b..3781d74088a7 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -692,6 +692,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
"J Toggle showing number of jump sources on targets\n"
"n Search next string\n"
"o Toggle disassembler output/simplified view\n"
+ "O Bump offset level (jump targets -> +call -> all -> cycle thru)\n"
"s Toggle source code view\n"
"t Circulate percent, total period, samples view\n"
"/ Search string\n"
@@ -719,6 +720,10 @@ static int annotate_browser__run(struct annotate_browser *browser,
notes->options->use_offset = !notes->options->use_offset;
annotation__update_column_widths(notes);
continue;
+ case 'O':
+ if (++notes->options->offset_level > ANNOTATION__MAX_OFFSET_LEVEL)
+ notes->options->offset_level = ANNOTATION__MIN_OFFSET_LEVEL;
+ continue;
case 'j':
notes->options->jump_arrows = !notes->options->jump_arrows;
continue;
--
2.14.3