perf annotate browser: Show extra title line with event information
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 6920e2854e9a16226ca57199d48fd6b68819f6d5 Gitweb: https://git.kernel.org/tip/6920e2854e9a16226ca57199d48fd6b68819f6d5 Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Mon, 2 Apr 2018 16:18:45 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 3 Apr 2018 15:23:11 -0300
perf annotate browser: Show extra title line with event information
So at the top we'll have two lines, like this, from 'perf report':
# perf report --group --ignore-vmlinux
=====================================================================================================
Samples: 46 of events 'cycles', 4000 Hz, Event count (approx.): 5154895
_raw_spin_lock_irqsave /proc/kcore
Percent │ nop
│ push %rbx
0.00 14.29 0.00 │ pushfq
9.09 0.00 0.00 │ pop %rax
9.09 0.00 20.00 │ nop
│ mov %rax,%rbx
│ cli
4.55 7.14 0.00 │ nop
│ xor %eax,%eax
│ mov $0x1,%edx
│ lock cmpxchg %edx,(%rdi)
77.27 78.57 70.00 │ test %eax,%eax
│ ↓ jne 2b
│ mov %rbx,%rax
0.00 0.00 10.00 │ pop %rbx
│ ← retq
│2b: mov %eax,%esi
│ → callq queued_spin_lock_slowpath
│ mov %rbx,%rax
│ pop %rbx
Press 'h' for help on│key bindings
===================================================================================================== 9.09 + 9.09 + 4.55 + 77.27 = 100
14.29 + 7.14 + 78.57 = 100
20 + 70 + 10 = 100
We can do the math by using 't' to toggle from 'percent' to nr
=====================================================================================================
Samples: 46 of events 'cycles', 4000 Hz, Event count (approx.): 5154895 _raw_spin_lock_irqsave /proc/kcore
Period │ nop
│ push %rbx
0 79273 0 │ pushfq
190455 0 0 │ pop %rax
198038 0 3045 │ nop
│ mov %rax,%rbx
│ cli
217233 32562 0 │ nop
│ xor %eax,%eax
│ mov $0x1,%edx
│ lock cmpxchg %edx,(%rdi)
3421649 979174 28273 │ test %eax,%eax
│ ↓ jne 2b
│ mov %rbx,%rax
0 0 5193 │ pop %rbx
│ ← retq
│2b: mov %eax,%esi
│ → callq queued_spin_lock_slowpath
│ mov %rbx,%rax
│ pop %rbx
Press 'h' for help on│key bindings=====================================================================================================
79273 + 190455 + 198038 + 3045 + 217233 + 32562 + 3421649 + 979174 + 28273 + 5193 = 5154895
Or number of samples:
=====================================================================================================
ooSamples: 46 of events 'cycles', 4000 Hz, Event count (approx.): 5154895 _raw_spin_lock_irqsave /proc/kcore
Samples │ nop
│ push %rbx
0 2 0 │ pushfq
2 0 0 │ pop %rax
2 0 2 │ nop
│ mov %rax,%rbx
│ cli
1 1 0 │ nop
│ xor %eax,%eax
│ mov $0x1,%edx
│ lock cmpxchg %edx,(%rdi)
17 11 7 │ test %eax,%eax
│ ↓ jne 2b
│ mov %rbx,%rax
0 0 1 │ pop %rbx
│ ← retq
│2b: mov %eax,%esi
│ → callq queued_spin_lock_slowpath
│ mov %rbx,%rax
│ pop %rbxPress 'h' for help on key bindings
=====================================================================================================
2 + 2 + 2 + 2 + 1 + 1 + 17 + 11 + 7 + 1 = 46
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
--- tools/perf/ui/browsers/annotate.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
tools/perf/ui/browsers/annotate.c +27 -4
@@ -592,21 +592,40 @@ bool annotate_browser__continue_search_reverse(struct annotate_browser *browser,return __annotate_browser__search_reverse (browser); } +static int annotate_browser__show (struct ui_browser *browser,char *title,const char *help) +{ +struct map_symbol *ms = browser->priv; +struct symbol *sym = ms->sym; +char symbol_dso[SYM_TITLE_MAX_SIZE ]; + +if (ui_browser__show (browser, title, help) <0 ) +return -1 ; + +sym_title (sym, ms->map, symbol_dso,sizeof (symbol_dso)); + +ui_browser__gotorc_title (browser,0 ,0 ); +ui_browser__set_color (browser,HE_COLORSET_ROOT ); +ui_browser__write_nstring (browser, symbol_dso, browser->width +1 ); +return 0 ; +} +static int annotate_browser__run (struct annotate_browser *browser,struct perf_evsel *evsel,struct hist_browser_timer *hbt) {struct rb_node *nd =NULL ; +struct hists *hists =evsel__hists (evsel);struct map_symbol *ms = browser->b.priv;struct symbol *sym = ms->sym;struct annotation *notes =symbol__annotation (ms->sym);const char *help ="Press 'h' for help on key bindings" ;int delay_secs = hbt ? hbt->refresh :0 ; +char title[256 ];int key; -char title[SYM_TITLE_MAX_SIZE ]; -sym_title (sym, ms->map, title,sizeof (title)); -if (ui_browser__show (&browser->b, title, help) <0 ) +annotation__scnprintf_samples_period (notes, title,sizeof (title), evsel); + +if (annotate_browser__show (&browser->b, title, help) <0 )return -1 ;annotate_browser__calc_percent (browser, evsel);
@@ -637,8 +656,11 @@ static int annotate_browser__run(struct annotate_browser *browser,if (hbt) hbt->timer (hbt->arg); -if (delay_secs !=0 ) +if (delay_secs !=0 ) {symbol__annotate_decay_histogram (sym, evsel->idx); +hists__scnprintf_title (hists, title,sizeof (title)); +annotate_browser__show (&browser->b, title, help); + }continue ;case K_TAB :if (nd !=NULL ) {
@@ -812,6 +834,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, .seek = ui_browser__list_head_seek, .write = annotate_browser__write, .filter = disasm_line__filter, + .extra_title_lines = 1, /* for hists__scnprintf_title() */ .priv = &ms, .use_navkeypressed = true, },