perf annotate: Remove disasm__calc_percent() from disasm_line__print()
Remove disasm__calc_percent() from disasm_line__print(), because we already have the data calculated in struct annotation_line. 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-20-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
8b4c74dc5c
commit
f681d593d1
@ -226,6 +226,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,
|
|||||||
static void perf_top__show_details(struct perf_top *top)
|
static void perf_top__show_details(struct perf_top *top)
|
||||||
{
|
{
|
||||||
struct hist_entry *he = top->sym_filter_entry;
|
struct hist_entry *he = top->sym_filter_entry;
|
||||||
|
struct perf_evsel *evsel = hists_to_evsel(he->hists);
|
||||||
struct annotation *notes;
|
struct annotation *notes;
|
||||||
struct symbol *symbol;
|
struct symbol *symbol;
|
||||||
int more;
|
int more;
|
||||||
@ -238,6 +239,8 @@ static void perf_top__show_details(struct perf_top *top)
|
|||||||
|
|
||||||
pthread_mutex_lock(¬es->lock);
|
pthread_mutex_lock(¬es->lock);
|
||||||
|
|
||||||
|
symbol__calc_percent(symbol, evsel);
|
||||||
|
|
||||||
if (notes->src == NULL)
|
if (notes->src == NULL)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
|
|
||||||
|
@ -1145,41 +1145,19 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|||||||
static const char *prev_color;
|
static const char *prev_color;
|
||||||
|
|
||||||
if (dl->al.offset != -1) {
|
if (dl->al.offset != -1) {
|
||||||
const char *path = NULL;
|
double max_percent = 0.0;
|
||||||
double percent, max_percent = 0.0;
|
|
||||||
double *ppercents = &percent;
|
|
||||||
struct sym_hist_entry sample;
|
|
||||||
struct sym_hist_entry *psamples = &sample;
|
|
||||||
int i, nr_percent = 1;
|
int i, nr_percent = 1;
|
||||||
const char *color;
|
const char *color;
|
||||||
struct annotation *notes = symbol__annotation(sym);
|
struct annotation *notes = symbol__annotation(sym);
|
||||||
s64 offset = dl->al.offset;
|
s64 offset = dl->al.offset;
|
||||||
const u64 addr = start + offset;
|
const u64 addr = start + offset;
|
||||||
struct annotation_line *next;
|
|
||||||
struct block_range *br;
|
struct block_range *br;
|
||||||
|
|
||||||
next = annotation_line__next(&dl->al, ¬es->src->source);
|
for (i = 0; i < dl->al.samples_nr; i++) {
|
||||||
|
struct annotation_data *sample = &dl->al.samples[i];
|
||||||
|
|
||||||
if (perf_evsel__is_group_event(evsel)) {
|
if (sample->percent > max_percent)
|
||||||
nr_percent = evsel->nr_members;
|
max_percent = sample->percent;
|
||||||
ppercents = calloc(nr_percent, sizeof(double));
|
|
||||||
psamples = calloc(nr_percent, sizeof(struct sym_hist_entry));
|
|
||||||
if (ppercents == NULL || psamples == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < nr_percent; i++) {
|
|
||||||
percent = disasm__calc_percent(notes,
|
|
||||||
notes->src->lines ? i : evsel->idx + i,
|
|
||||||
offset,
|
|
||||||
next ? next->offset : (s64) len,
|
|
||||||
&path, &sample);
|
|
||||||
|
|
||||||
ppercents[i] = percent;
|
|
||||||
psamples[i] = sample;
|
|
||||||
if (percent > max_percent)
|
|
||||||
max_percent = percent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max_percent < min_pcnt)
|
if (max_percent < min_pcnt)
|
||||||
@ -1204,28 +1182,28 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|||||||
* the same color than the percentage. Don't print it
|
* the same color than the percentage. Don't print it
|
||||||
* twice for close colored addr with the same filename:line
|
* twice for close colored addr with the same filename:line
|
||||||
*/
|
*/
|
||||||
if (path) {
|
if (dl->al.path) {
|
||||||
if (!prev_line || strcmp(prev_line, path)
|
if (!prev_line || strcmp(prev_line, dl->al.path)
|
||||||
|| color != prev_color) {
|
|| color != prev_color) {
|
||||||
color_fprintf(stdout, color, " %s", path);
|
color_fprintf(stdout, color, " %s", dl->al.path);
|
||||||
prev_line = path;
|
prev_line = dl->al.path;
|
||||||
prev_color = color;
|
prev_color = color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nr_percent; i++) {
|
for (i = 0; i < nr_percent; i++) {
|
||||||
percent = ppercents[i];
|
struct annotation_data *sample = &dl->al.samples[i];
|
||||||
sample = psamples[i];
|
|
||||||
color = get_percent_color(percent);
|
color = get_percent_color(sample->percent);
|
||||||
|
|
||||||
if (symbol_conf.show_total_period)
|
if (symbol_conf.show_total_period)
|
||||||
color_fprintf(stdout, color, " %11" PRIu64,
|
color_fprintf(stdout, color, " %11" PRIu64,
|
||||||
sample.period);
|
sample->he.period);
|
||||||
else if (symbol_conf.show_nr_samples)
|
else if (symbol_conf.show_nr_samples)
|
||||||
color_fprintf(stdout, color, " %7" PRIu64,
|
color_fprintf(stdout, color, " %7" PRIu64,
|
||||||
sample.nr_samples);
|
sample->he.nr_samples);
|
||||||
else
|
else
|
||||||
color_fprintf(stdout, color, " %7.2f", percent);
|
color_fprintf(stdout, color, " %7.2f", sample->percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(" : ");
|
printf(" : ");
|
||||||
@ -1235,13 +1213,6 @@ static int disasm_line__print(struct disasm_line *dl, struct symbol *sym, u64 st
|
|||||||
color_fprintf(stdout, annotate__asm_color(br), "%s", dl->al.line);
|
color_fprintf(stdout, annotate__asm_color(br), "%s", dl->al.line);
|
||||||
annotate__branch_printf(br, addr);
|
annotate__branch_printf(br, addr);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if (ppercents != &percent)
|
|
||||||
free(ppercents);
|
|
||||||
|
|
||||||
if (psamples != &sample)
|
|
||||||
free(psamples);
|
|
||||||
|
|
||||||
} else if (max_lines && printed >= max_lines)
|
} else if (max_lines && printed >= max_lines)
|
||||||
return 1;
|
return 1;
|
||||||
else {
|
else {
|
||||||
|
Loading…
Reference in New Issue
Block a user