diff options
author | Martin Liška <mliska@suse.cz> | 2015-06-19 15:10:43 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-06-19 15:39:18 -0400 |
commit | 0c4a5bcea4609948375173cdea8d73783110a75e (patch) | |
tree | 3d34e9c1225a92194ff13a9896f9600874e48131 /tools/perf/ui/browsers/annotate.c | |
parent | a5499b37197ab4b5fed101370df7ccadacbb4340 (diff) |
perf annotate: Display total number of samples with --show-total-period
To compare two records on an instruction base, with --show-total-period
option provided, display total number of samples that belong to a line
in assembly language.
New hot key 't' is introduced for 'perf annotate' TUI.
Signed-off-by: Martin Liska <mliska@suse.cz>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/5583E26D.1040407@suse.cz
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/ui/browsers/annotate.c')
-rw-r--r-- | tools/perf/ui/browsers/annotate.c | 60 |
1 files changed, 43 insertions, 17 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index acb0e23b138e..5995a8bd7c69 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -11,16 +11,21 @@ | |||
11 | #include "../../util/evsel.h" | 11 | #include "../../util/evsel.h" |
12 | #include <pthread.h> | 12 | #include <pthread.h> |
13 | 13 | ||
14 | struct disasm_line_samples { | ||
15 | double percent; | ||
16 | u64 nr; | ||
17 | }; | ||
18 | |||
14 | struct browser_disasm_line { | 19 | struct browser_disasm_line { |
15 | struct rb_node rb_node; | 20 | struct rb_node rb_node; |
16 | u32 idx; | 21 | u32 idx; |
17 | int idx_asm; | 22 | int idx_asm; |
18 | int jump_sources; | 23 | int jump_sources; |
19 | /* | 24 | /* |
20 | * actual length of this array is saved on the nr_events field | 25 | * actual length of this array is saved on the nr_events field |
21 | * of the struct annotate_browser | 26 | * of the struct annotate_browser |
22 | */ | 27 | */ |
23 | double percent[1]; | 28 | struct disasm_line_samples samples[1]; |
24 | }; | 29 | }; |
25 | 30 | ||
26 | static struct annotate_browser_opt { | 31 | static struct annotate_browser_opt { |
@@ -28,7 +33,8 @@ static struct annotate_browser_opt { | |||
28 | use_offset, | 33 | use_offset, |
29 | jump_arrows, | 34 | jump_arrows, |
30 | show_linenr, | 35 | show_linenr, |
31 | show_nr_jumps; | 36 | show_nr_jumps, |
37 | show_total_period; | ||
32 | } annotate_browser__opts = { | 38 | } annotate_browser__opts = { |
33 | .use_offset = true, | 39 | .use_offset = true, |
34 | .jump_arrows = true, | 40 | .jump_arrows = true, |
@@ -105,15 +111,20 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
105 | char bf[256]; | 111 | char bf[256]; |
106 | 112 | ||
107 | for (i = 0; i < ab->nr_events; i++) { | 113 | for (i = 0; i < ab->nr_events; i++) { |
108 | if (bdl->percent[i] > percent_max) | 114 | if (bdl->samples[i].percent > percent_max) |
109 | percent_max = bdl->percent[i]; | 115 | percent_max = bdl->samples[i].percent; |
110 | } | 116 | } |
111 | 117 | ||
112 | if (dl->offset != -1 && percent_max != 0.0) { | 118 | if (dl->offset != -1 && percent_max != 0.0) { |
113 | for (i = 0; i < ab->nr_events; i++) { | 119 | for (i = 0; i < ab->nr_events; i++) { |
114 | ui_browser__set_percent_color(browser, bdl->percent[i], | 120 | ui_browser__set_percent_color(browser, |
121 | bdl->samples[i].percent, | ||
115 | current_entry); | 122 | current_entry); |
116 | slsmg_printf("%6.2f ", bdl->percent[i]); | 123 | if (annotate_browser__opts.show_total_period) |
124 | slsmg_printf("%6" PRIu64 " ", | ||
125 | bdl->samples[i].nr); | ||
126 | else | ||
127 | slsmg_printf("%6.2f ", bdl->samples[i].percent); | ||
117 | } | 128 | } |
118 | } else { | 129 | } else { |
119 | ui_browser__set_percent_color(browser, 0, current_entry); | 130 | ui_browser__set_percent_color(browser, 0, current_entry); |
@@ -273,9 +284,9 @@ static int disasm__cmp(struct browser_disasm_line *a, | |||
273 | int i; | 284 | int i; |
274 | 285 | ||
275 | for (i = 0; i < nr_pcnt; i++) { | 286 | for (i = 0; i < nr_pcnt; i++) { |
276 | if (a->percent[i] == b->percent[i]) | 287 | if (a->samples[i].percent == b->samples[i].percent) |
277 | continue; | 288 | continue; |
278 | return a->percent[i] < b->percent[i]; | 289 | return a->samples[i].percent < b->samples[i].percent; |
279 | } | 290 | } |
280 | return 0; | 291 | return 0; |
281 | } | 292 | } |
@@ -366,14 +377,17 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
366 | next = disasm__get_next_ip_line(¬es->src->source, pos); | 377 | next = disasm__get_next_ip_line(¬es->src->source, pos); |
367 | 378 | ||
368 | for (i = 0; i < browser->nr_events; i++) { | 379 | for (i = 0; i < browser->nr_events; i++) { |
369 | bpos->percent[i] = disasm__calc_percent(notes, | 380 | u64 nr_samples; |
381 | |||
382 | bpos->samples[i].percent = disasm__calc_percent(notes, | ||
370 | evsel->idx + i, | 383 | evsel->idx + i, |
371 | pos->offset, | 384 | pos->offset, |
372 | next ? next->offset : len, | 385 | next ? next->offset : len, |
373 | &path); | 386 | &path, &nr_samples); |
387 | bpos->samples[i].nr = nr_samples; | ||
374 | 388 | ||
375 | if (max_percent < bpos->percent[i]) | 389 | if (max_percent < bpos->samples[i].percent) |
376 | max_percent = bpos->percent[i]; | 390 | max_percent = bpos->samples[i].percent; |
377 | } | 391 | } |
378 | 392 | ||
379 | if (max_percent < 0.01) { | 393 | if (max_percent < 0.01) { |
@@ -737,6 +751,7 @@ static int annotate_browser__run(struct annotate_browser *browser, | |||
737 | "n Search next string\n" | 751 | "n Search next string\n" |
738 | "o Toggle disassembler output/simplified view\n" | 752 | "o Toggle disassembler output/simplified view\n" |
739 | "s Toggle source code view\n" | 753 | "s Toggle source code view\n" |
754 | "t Toggle total period view\n" | ||
740 | "/ Search string\n" | 755 | "/ Search string\n" |
741 | "k Toggle line numbers\n" | 756 | "k Toggle line numbers\n" |
742 | "r Run available scripts\n" | 757 | "r Run available scripts\n" |
@@ -812,6 +827,11 @@ show_sup_ins: | |||
812 | ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); | 827 | ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions."); |
813 | } | 828 | } |
814 | continue; | 829 | continue; |
830 | case 't': | ||
831 | annotate_browser__opts.show_total_period = | ||
832 | !annotate_browser__opts.show_total_period; | ||
833 | annotate_browser__update_addr_width(browser); | ||
834 | continue; | ||
815 | case K_LEFT: | 835 | case K_LEFT: |
816 | case K_ESC: | 836 | case K_ESC: |
817 | case 'q': | 837 | case 'q': |
@@ -832,6 +852,10 @@ out: | |||
832 | int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel, | 852 | int map_symbol__tui_annotate(struct map_symbol *ms, struct perf_evsel *evsel, |
833 | struct hist_browser_timer *hbt) | 853 | struct hist_browser_timer *hbt) |
834 | { | 854 | { |
855 | /* Set default value for show_total_period. */ | ||
856 | annotate_browser__opts.show_total_period = | ||
857 | symbol_conf.show_total_period; | ||
858 | |||
835 | return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt); | 859 | return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt); |
836 | } | 860 | } |
837 | 861 | ||
@@ -929,7 +953,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
929 | 953 | ||
930 | if (perf_evsel__is_group_event(evsel)) { | 954 | if (perf_evsel__is_group_event(evsel)) { |
931 | nr_pcnt = evsel->nr_members; | 955 | nr_pcnt = evsel->nr_members; |
932 | sizeof_bdl += sizeof(double) * (nr_pcnt - 1); | 956 | sizeof_bdl += sizeof(struct disasm_line_samples) * |
957 | (nr_pcnt - 1); | ||
933 | } | 958 | } |
934 | 959 | ||
935 | if (symbol__annotate(sym, map, sizeof_bdl) < 0) { | 960 | if (symbol__annotate(sym, map, sizeof_bdl) < 0) { |
@@ -1006,6 +1031,7 @@ static struct annotate_config { | |||
1006 | ANNOTATE_CFG(show_linenr), | 1031 | ANNOTATE_CFG(show_linenr), |
1007 | ANNOTATE_CFG(show_nr_jumps), | 1032 | ANNOTATE_CFG(show_nr_jumps), |
1008 | ANNOTATE_CFG(use_offset), | 1033 | ANNOTATE_CFG(use_offset), |
1034 | ANNOTATE_CFG(show_total_period), | ||
1009 | }; | 1035 | }; |
1010 | 1036 | ||
1011 | #undef ANNOTATE_CFG | 1037 | #undef ANNOTATE_CFG |