perf annotate: Fix wrong --show-total-period option showing number of samples
PATCH v2 3/9 perf annotate: Fix wrong --show-total-period option showing number of samples
Currently the --show-total-period option of perf-annotate is different from perf-report's.
For example, perf-report ordinarily shows period and number of samples.
# Overhead Samples Period Command Shared Object Symbol
# ........ ............ ............ ....... .............. ............
#
9.83% 102 84813704 test test [.] knapsackBut --show-total-period of perf-annotate has the problem that show number of samples, not period.
So fix this option to show period instead of number of samples.
Before:
Percent | Source code & Disassembly of old for cycles:ppp (102 samples)
-----------------------------------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 0000000000400816 <knapsack>:
: knapsack():
1 : 400816: push %rbpAfter:
Percent | Source code & Disassembly of old for cycles:ppp (84813704 event count)
----------------------------------------------------------------------------------
:
:
:
: Disassembly of section .text:
:
: 0000000000400816 <knapsack>:
: knapsack():743737 : 400816: push %rbp
--- tools/perf/builtin-annotate.c | 4 +-- tools/perf/builtin-report.c | 13 ++++++---- tools/perf/builtin-top.c | 6 +++-- tools/perf/util/annotate.c | 57 +++++++++++++++++++++++++++++++++++++------ tools/perf/util/annotate.h | 4 ++- 5 files changed, 65 insertions(+), 19 deletions(-)
tools/perf/builtin-annotate.c +1 -3
@@ -177,14 +177,12 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,*/ process_branch_stack (sample->branch_stack, al, sample); - sample->period =1 ; sample->weight =1 ; - he =hists__add_entry (hists, al,NULL ,NULL ,NULL , sample, true);if (he ==NULL )return -ENOMEM ; - ret =hist_entry__inc_addr_samples (he, evsel->idx, al->addr); + ret =hist_entry__inc_addr_samples (he, sample, evsel->idx, al->addr);hists__inc_nr_samples (hists, true);return ret; }
tools/perf/builtin-report.c +8 -5
@@ -113,13 +113,14 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,struct report *rep = arg;struct hist_entry *he = iter->he;struct perf_evsel *evsel = iter->evsel; +struct perf_sample *sample = iter->sample;struct mem_info *mi;struct branch_info *bi;if (!ui__has_annotation ())return 0 ; -hist__account_cycles (iter->sample->branch_stack, al, iter->sample, +hist__account_cycles (sample->branch_stack, al, sample, rep->nonany_branch_mode);if (sort__mode ==SORT_MODE__BRANCH ) {
@@ -136,14 +137,16 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,if (err) goto out; - err =hist_entry__inc_addr_samples (he, evsel->idx, al->addr); + err =hist_entry__inc_addr_samples (he, sample, + evsel->idx, al->addr); }else if (symbol_conf.cumulate_callchain) {if (single) - err =hist_entry__inc_addr_samples (he, evsel->idx, - al->addr); + err =hist_entry__inc_addr_samples (he, sample, + evsel->idx, al->addr); }else { - err =hist_entry__inc_addr_samples (he, evsel->idx, al->addr); + err =hist_entry__inc_addr_samples (he, sample, + evsel->idx, al->addr); } out:
tools/perf/builtin-top.c +4 -2
@@ -183,6 +183,7 @@ static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip)static void perf_top__record_precise_ip (struct perf_top *top,struct hist_entry *he, +struct perf_sample *sample,int counter,u64 ip) {struct annotation *notes;
@@ -199,7 +200,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,if (pthread_mutex_trylock (¬es->lock))return ; - err =hist_entry__inc_addr_samples (he, counter, ip); + err =hist_entry__inc_addr_samples (he, sample, counter, ip);pthread_mutex_unlock (¬es->lock);
@@ -671,7 +672,8 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,struct perf_evsel *evsel = iter->evsel;if (perf_hpp_list.sym && single) -perf_top__record_precise_ip (top, he, evsel->idx, al->addr); +perf_top__record_precise_ip (top, he, iter->sample, + evsel->idx, al->addr);hist__account_cycles (iter->sample->branch_stack, al, iter->sample, !(top->record_opts.branch_stack &PERF_SAMPLE_BRANCH_ANY ));
tools/perf/util/annotate.c +49 -8
110 lines not on this page · raw message
tools/perf/util/annotate.h +3 -1
@@ -88,6 +88,7 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,struct sym_hist {u64 total_samples; +u64 total_period;struct sym_hist_entry addr[0 ]; };
@@ -160,7 +161,8 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,struct addr_map_symbol *start, unsigned cycles); -int hist_entry__inc_addr_samples (struct hist_entry *he,int evidx,u64 addr); +int hist_entry__inc_addr_samples (struct hist_entry *he,struct perf_sample *sample, +int evidx,u64 addr);int symbol__alloc_hist (struct symbol *sym);void symbol__annotate_zero_histograms (struct symbol *sym);
Signature · 1 line
2.7.4