diff options
author | Jiri Olsa <jolsa@kernel.org> | 2017-10-11 11:01:48 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-11-16 12:49:45 -0500 |
commit | 3ab6db8d0f3b19b93a8de25e3b7ab5fdaac47679 (patch) | |
tree | e547542a8648315f88bdc3d38ab9cc9f787707a2 /tools/perf/ui/browsers/annotate.c | |
parent | 29971f9a82a5d005b37d65fbb73edaf9073279b0 (diff) |
perf annotate browser: Use samples data from struct annotation_line
We now carry the data in 'struct annotation_line', so using it instead
of samples from 'struct browser_disasm_line' and removing it and its
setup.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20171011150158.11895-26-jolsa@kernel.org
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 | 57 |
1 files changed, 20 insertions, 37 deletions
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 613682432940..5d99429a03bc 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c | |||
@@ -29,11 +29,6 @@ struct browser_disasm_line { | |||
29 | u32 idx; | 29 | u32 idx; |
30 | int idx_asm; | 30 | int idx_asm; |
31 | int jump_sources; | 31 | int jump_sources; |
32 | /* | ||
33 | * actual length of this array is saved on the nr_events field | ||
34 | * of the struct annotate_browser | ||
35 | */ | ||
36 | struct disasm_line_samples samples[1]; | ||
37 | }; | 32 | }; |
38 | 33 | ||
39 | static struct annotate_browser_opt { | 34 | static struct annotate_browser_opt { |
@@ -76,9 +71,7 @@ struct annotate_browser { | |||
76 | 71 | ||
77 | static inline struct browser_disasm_line *disasm_line__browser(struct disasm_line *dl) | 72 | static inline struct browser_disasm_line *disasm_line__browser(struct disasm_line *dl) |
78 | { | 73 | { |
79 | struct annotation_line *al = &dl->al; | 74 | return (void *) dl - sizeof(struct browser_disasm_line); |
80 | |||
81 | return (void *) al - al->privsize; | ||
82 | } | 75 | } |
83 | 76 | ||
84 | static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, | 77 | static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, |
@@ -139,8 +132,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
139 | bool show_title = false; | 132 | bool show_title = false; |
140 | 133 | ||
141 | for (i = 0; i < ab->nr_events; i++) { | 134 | for (i = 0; i < ab->nr_events; i++) { |
142 | if (bdl->samples[i].percent > percent_max) | 135 | if (dl->al.samples[i].percent > percent_max) |
143 | percent_max = bdl->samples[i].percent; | 136 | percent_max = dl->al.samples[i].percent; |
144 | } | 137 | } |
145 | 138 | ||
146 | if ((row == 0) && (dl->al.offset == -1 || percent_max == 0.0)) { | 139 | if ((row == 0) && (dl->al.offset == -1 || percent_max == 0.0)) { |
@@ -154,17 +147,17 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int | |||
154 | if (dl->al.offset != -1 && percent_max != 0.0) { | 147 | if (dl->al.offset != -1 && percent_max != 0.0) { |
155 | for (i = 0; i < ab->nr_events; i++) { | 148 | for (i = 0; i < ab->nr_events; i++) { |
156 | ui_browser__set_percent_color(browser, | 149 | ui_browser__set_percent_color(browser, |
157 | bdl->samples[i].percent, | 150 | dl->al.samples[i].percent, |
158 | current_entry); | 151 | current_entry); |
159 | if (annotate_browser__opts.show_total_period) { | 152 | if (annotate_browser__opts.show_total_period) { |
160 | ui_browser__printf(browser, "%11" PRIu64 " ", | 153 | ui_browser__printf(browser, "%11" PRIu64 " ", |
161 | bdl->samples[i].he.period); | 154 | dl->al.samples[i].he.period); |
162 | } else if (annotate_browser__opts.show_nr_samples) { | 155 | } else if (annotate_browser__opts.show_nr_samples) { |
163 | ui_browser__printf(browser, "%6" PRIu64 " ", | 156 | ui_browser__printf(browser, "%6" PRIu64 " ", |
164 | bdl->samples[i].he.nr_samples); | 157 | dl->al.samples[i].he.nr_samples); |
165 | } else { | 158 | } else { |
166 | ui_browser__printf(browser, "%6.2f ", | 159 | ui_browser__printf(browser, "%6.2f ", |
167 | bdl->samples[i].percent); | 160 | dl->al.samples[i].percent); |
168 | } | 161 | } |
169 | } | 162 | } |
170 | } else { | 163 | } else { |
@@ -363,11 +356,9 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser) | |||
363 | return ret; | 356 | return ret; |
364 | } | 357 | } |
365 | 358 | ||
366 | static int disasm__cmp(struct disasm_line *da, | 359 | static int disasm__cmp(struct annotation_line *a, |
367 | struct disasm_line *db, int nr_pcnt) | 360 | struct annotation_line *b, int nr_pcnt) |
368 | { | 361 | { |
369 | struct browser_disasm_line *a = disasm_line__browser(da); | ||
370 | struct browser_disasm_line *b = disasm_line__browser(db); | ||
371 | int i; | 362 | int i; |
372 | 363 | ||
373 | for (i = 0; i < nr_pcnt; i++) { | 364 | for (i = 0; i < nr_pcnt; i++) { |
@@ -378,24 +369,24 @@ static int disasm__cmp(struct disasm_line *da, | |||
378 | return 0; | 369 | return 0; |
379 | } | 370 | } |
380 | 371 | ||
381 | static void disasm_rb_tree__insert(struct rb_root *root, struct disasm_line *dl, | 372 | static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line *al, |
382 | int nr_events) | 373 | int nr_events) |
383 | { | 374 | { |
384 | struct rb_node **p = &root->rb_node; | 375 | struct rb_node **p = &root->rb_node; |
385 | struct rb_node *parent = NULL; | 376 | struct rb_node *parent = NULL; |
386 | struct disasm_line *l; | 377 | struct annotation_line *l; |
387 | 378 | ||
388 | while (*p != NULL) { | 379 | while (*p != NULL) { |
389 | parent = *p; | 380 | parent = *p; |
390 | l = rb_entry(parent, struct disasm_line, al.rb_node); | 381 | l = rb_entry(parent, struct annotation_line, rb_node); |
391 | 382 | ||
392 | if (disasm__cmp(dl, l, nr_events)) | 383 | if (disasm__cmp(al, l, nr_events)) |
393 | p = &(*p)->rb_left; | 384 | p = &(*p)->rb_left; |
394 | else | 385 | else |
395 | p = &(*p)->rb_right; | 386 | p = &(*p)->rb_right; |
396 | } | 387 | } |
397 | rb_link_node(&dl->al.rb_node, parent, p); | 388 | rb_link_node(&al->rb_node, parent, p); |
398 | rb_insert_color(&dl->al.rb_node, root); | 389 | rb_insert_color(&al->rb_node, root); |
399 | } | 390 | } |
400 | 391 | ||
401 | static void annotate_browser__set_top(struct annotate_browser *browser, | 392 | static void annotate_browser__set_top(struct annotate_browser *browser, |
@@ -453,7 +444,6 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
453 | symbol__calc_percent(sym, evsel); | 444 | symbol__calc_percent(sym, evsel); |
454 | 445 | ||
455 | list_for_each_entry(pos, ¬es->src->source, al.node) { | 446 | list_for_each_entry(pos, ¬es->src->source, al.node) { |
456 | struct browser_disasm_line *bpos = disasm_line__browser(pos); | ||
457 | double max_percent = 0.0; | 447 | double max_percent = 0.0; |
458 | int i; | 448 | int i; |
459 | 449 | ||
@@ -465,18 +455,15 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, | |||
465 | for (i = 0; i < browser->nr_events; i++) { | 455 | for (i = 0; i < browser->nr_events; i++) { |
466 | struct annotation_data *sample = &pos->al.samples[i]; | 456 | struct annotation_data *sample = &pos->al.samples[i]; |
467 | 457 | ||
468 | bpos->samples[i].percent = sample->percent; | 458 | if (max_percent < sample->percent) |
469 | bpos->samples[i].he = sample->he; | 459 | max_percent = sample->percent; |
470 | |||
471 | if (max_percent < bpos->samples[i].percent) | ||
472 | max_percent = bpos->samples[i].percent; | ||
473 | } | 460 | } |
474 | 461 | ||
475 | if (max_percent < 0.01 && pos->al.ipc == 0) { | 462 | if (max_percent < 0.01 && pos->al.ipc == 0) { |
476 | RB_CLEAR_NODE(&pos->al.rb_node); | 463 | RB_CLEAR_NODE(&pos->al.rb_node); |
477 | continue; | 464 | continue; |
478 | } | 465 | } |
479 | disasm_rb_tree__insert(&browser->entries, pos, | 466 | disasm_rb_tree__insert(&browser->entries, &pos->al, |
480 | browser->nr_events); | 467 | browser->nr_events); |
481 | } | 468 | } |
482 | pthread_mutex_unlock(¬es->lock); | 469 | pthread_mutex_unlock(¬es->lock); |
@@ -1096,7 +1083,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1096 | }; | 1083 | }; |
1097 | int ret = -1, err; | 1084 | int ret = -1, err; |
1098 | int nr_pcnt = 1; | 1085 | int nr_pcnt = 1; |
1099 | size_t sizeof_bdl = sizeof(struct browser_disasm_line); | ||
1100 | 1086 | ||
1101 | if (sym == NULL) | 1087 | if (sym == NULL) |
1102 | return -1; | 1088 | return -1; |
@@ -1112,14 +1098,11 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, | |||
1112 | return -1; | 1098 | return -1; |
1113 | } | 1099 | } |
1114 | 1100 | ||
1115 | if (perf_evsel__is_group_event(evsel)) { | 1101 | if (perf_evsel__is_group_event(evsel)) |
1116 | nr_pcnt = evsel->nr_members; | 1102 | nr_pcnt = evsel->nr_members; |
1117 | sizeof_bdl += sizeof(struct disasm_line_samples) * | ||
1118 | (nr_pcnt - 1); | ||
1119 | } | ||
1120 | 1103 | ||
1121 | err = symbol__annotate(sym, map, evsel, | 1104 | err = symbol__annotate(sym, map, evsel, |
1122 | sizeof_bdl, &browser.arch, | 1105 | sizeof(struct browser_disasm_line), &browser.arch, |
1123 | perf_evsel__env_cpuid(evsel)); | 1106 | perf_evsel__env_cpuid(evsel)); |
1124 | if (err) { | 1107 | if (err) { |
1125 | char msg[BUFSIZ]; | 1108 | char msg[BUFSIZ]; |