Commit 3ab6db8d authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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: default avatarJiri 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 29971f9a
...@@ -29,11 +29,6 @@ struct browser_disasm_line { ...@@ -29,11 +29,6 @@ struct browser_disasm_line {
u32 idx; u32 idx;
int idx_asm; int idx_asm;
int jump_sources; int jump_sources;
/*
* actual length of this array is saved on the nr_events field
* of the struct annotate_browser
*/
struct disasm_line_samples samples[1];
}; };
static struct annotate_browser_opt { static struct annotate_browser_opt {
...@@ -76,9 +71,7 @@ struct annotate_browser { ...@@ -76,9 +71,7 @@ struct annotate_browser {
static inline struct browser_disasm_line *disasm_line__browser(struct disasm_line *dl) static inline struct browser_disasm_line *disasm_line__browser(struct disasm_line *dl)
{ {
struct annotation_line *al = &dl->al; return (void *) dl - sizeof(struct browser_disasm_line);
return (void *) al - al->privsize;
} }
static bool disasm_line__filter(struct ui_browser *browser __maybe_unused, 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,8 +132,8 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
bool show_title = false; bool show_title = false;
for (i = 0; i < ab->nr_events; i++) { for (i = 0; i < ab->nr_events; i++) {
if (bdl->samples[i].percent > percent_max) if (dl->al.samples[i].percent > percent_max)
percent_max = bdl->samples[i].percent; percent_max = dl->al.samples[i].percent;
} }
if ((row == 0) && (dl->al.offset == -1 || percent_max == 0.0)) { 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,17 +147,17 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
if (dl->al.offset != -1 && percent_max != 0.0) { if (dl->al.offset != -1 && percent_max != 0.0) {
for (i = 0; i < ab->nr_events; i++) { for (i = 0; i < ab->nr_events; i++) {
ui_browser__set_percent_color(browser, ui_browser__set_percent_color(browser,
bdl->samples[i].percent, dl->al.samples[i].percent,
current_entry); current_entry);
if (annotate_browser__opts.show_total_period) { if (annotate_browser__opts.show_total_period) {
ui_browser__printf(browser, "%11" PRIu64 " ", ui_browser__printf(browser, "%11" PRIu64 " ",
bdl->samples[i].he.period); dl->al.samples[i].he.period);
} else if (annotate_browser__opts.show_nr_samples) { } else if (annotate_browser__opts.show_nr_samples) {
ui_browser__printf(browser, "%6" PRIu64 " ", ui_browser__printf(browser, "%6" PRIu64 " ",
bdl->samples[i].he.nr_samples); dl->al.samples[i].he.nr_samples);
} else { } else {
ui_browser__printf(browser, "%6.2f ", ui_browser__printf(browser, "%6.2f ",
bdl->samples[i].percent); dl->al.samples[i].percent);
} }
} }
} else { } else {
...@@ -363,11 +356,9 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser) ...@@ -363,11 +356,9 @@ static unsigned int annotate_browser__refresh(struct ui_browser *browser)
return ret; return ret;
} }
static int disasm__cmp(struct disasm_line *da, static int disasm__cmp(struct annotation_line *a,
struct disasm_line *db, int nr_pcnt) struct annotation_line *b, int nr_pcnt)
{ {
struct browser_disasm_line *a = disasm_line__browser(da);
struct browser_disasm_line *b = disasm_line__browser(db);
int i; int i;
for (i = 0; i < nr_pcnt; i++) { for (i = 0; i < nr_pcnt; i++) {
...@@ -378,24 +369,24 @@ static int disasm__cmp(struct disasm_line *da, ...@@ -378,24 +369,24 @@ static int disasm__cmp(struct disasm_line *da,
return 0; return 0;
} }
static void disasm_rb_tree__insert(struct rb_root *root, struct disasm_line *dl, static void disasm_rb_tree__insert(struct rb_root *root, struct annotation_line *al,
int nr_events) int nr_events)
{ {
struct rb_node **p = &root->rb_node; struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL; struct rb_node *parent = NULL;
struct disasm_line *l; struct annotation_line *l;
while (*p != NULL) { while (*p != NULL) {
parent = *p; parent = *p;
l = rb_entry(parent, struct disasm_line, al.rb_node); l = rb_entry(parent, struct annotation_line, rb_node);
if (disasm__cmp(dl, l, nr_events)) if (disasm__cmp(al, l, nr_events))
p = &(*p)->rb_left; p = &(*p)->rb_left;
else else
p = &(*p)->rb_right; p = &(*p)->rb_right;
} }
rb_link_node(&dl->al.rb_node, parent, p); rb_link_node(&al->rb_node, parent, p);
rb_insert_color(&dl->al.rb_node, root); rb_insert_color(&al->rb_node, root);
} }
static void annotate_browser__set_top(struct annotate_browser *browser, 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,7 +444,6 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
symbol__calc_percent(sym, evsel); symbol__calc_percent(sym, evsel);
list_for_each_entry(pos, &notes->src->source, al.node) { list_for_each_entry(pos, &notes->src->source, al.node) {
struct browser_disasm_line *bpos = disasm_line__browser(pos);
double max_percent = 0.0; double max_percent = 0.0;
int i; int i;
...@@ -465,18 +455,15 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, ...@@ -465,18 +455,15 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
for (i = 0; i < browser->nr_events; i++) { for (i = 0; i < browser->nr_events; i++) {
struct annotation_data *sample = &pos->al.samples[i]; struct annotation_data *sample = &pos->al.samples[i];
bpos->samples[i].percent = sample->percent; if (max_percent < sample->percent)
bpos->samples[i].he = sample->he; max_percent = sample->percent;
if (max_percent < bpos->samples[i].percent)
max_percent = bpos->samples[i].percent;
} }
if (max_percent < 0.01 && pos->al.ipc == 0) { if (max_percent < 0.01 && pos->al.ipc == 0) {
RB_CLEAR_NODE(&pos->al.rb_node); RB_CLEAR_NODE(&pos->al.rb_node);
continue; continue;
} }
disasm_rb_tree__insert(&browser->entries, pos, disasm_rb_tree__insert(&browser->entries, &pos->al,
browser->nr_events); browser->nr_events);
} }
pthread_mutex_unlock(&notes->lock); pthread_mutex_unlock(&notes->lock);
...@@ -1096,7 +1083,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, ...@@ -1096,7 +1083,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
}; };
int ret = -1, err; int ret = -1, err;
int nr_pcnt = 1; int nr_pcnt = 1;
size_t sizeof_bdl = sizeof(struct browser_disasm_line);
if (sym == NULL) if (sym == NULL)
return -1; return -1;
...@@ -1112,14 +1098,11 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, ...@@ -1112,14 +1098,11 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
return -1; return -1;
} }
if (perf_evsel__is_group_event(evsel)) { if (perf_evsel__is_group_event(evsel))
nr_pcnt = evsel->nr_members; nr_pcnt = evsel->nr_members;
sizeof_bdl += sizeof(struct disasm_line_samples) *
(nr_pcnt - 1);
}
err = symbol__annotate(sym, map, evsel, err = symbol__annotate(sym, map, evsel,
sizeof_bdl, &browser.arch, sizeof(struct browser_disasm_line), &browser.arch,
perf_evsel__env_cpuid(evsel)); perf_evsel__env_cpuid(evsel));
if (err) { if (err) {
char msg[BUFSIZ]; char msg[BUFSIZ];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment