aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.c
diff options
context:
space:
mode:
authorTaeung Song <treeze.taeung@gmail.com>2017-07-20 16:18:05 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-07-21 11:02:38 -0400
commit461c17f00f400f95116880d91d20a7fcd84263a9 (patch)
tree9e90d493d49065b41387ba79fc6645cafd8b0813 /tools/perf/util/annotate.c
parentbab89f6aed7e745893e009014354d0caaf62acf7 (diff)
perf annotate: Store the sample period in each histogram bucket
We'll use it soon, when fixing --show-total-period. Signed-off-by: Taeung Song <treeze.taeung@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1500500215-16646-1-git-send-email-treeze.taeung@gmail.com [ split from a larger patch, do the math in __symbol__inc_addr_samples() ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.c')
-rw-r--r--tools/perf/util/annotate.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index c2fe16d5e473..00e085fc945b 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -698,7 +698,7 @@ static int __symbol__account_cycles(struct annotation *notes,
698 698
699static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map, 699static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
700 struct annotation *notes, int evidx, u64 addr, 700 struct annotation *notes, int evidx, u64 addr,
701 struct perf_sample *sample __maybe_unused) 701 struct perf_sample *sample)
702{ 702{
703 unsigned offset; 703 unsigned offset;
704 struct sym_hist *h; 704 struct sym_hist *h;
@@ -716,10 +716,13 @@ static int __symbol__inc_addr_samples(struct symbol *sym, struct map *map,
716 h = annotation__histogram(notes, evidx); 716 h = annotation__histogram(notes, evidx);
717 h->nr_samples++; 717 h->nr_samples++;
718 h->addr[offset].nr_samples++; 718 h->addr[offset].nr_samples++;
719 h->period += sample->period;
720 h->addr[offset].period += sample->period;
719 721
720 pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64 722 pr_debug3("%#" PRIx64 " %s: period++ [addr: %#" PRIx64 ", %#" PRIx64
721 ", evidx=%d] => %" PRIu64 "\n", sym->start, sym->name, 723 ", evidx=%d] => nr_samples: %" PRIu64 ", period: %" PRIu64 "\n",
722 addr, addr - sym->start, evidx, h->addr[offset].nr_samples); 724 sym->start, sym->name, addr, addr - sym->start, evidx,
725 h->addr[offset].nr_samples, h->addr[offset].period);
723 return 0; 726 return 0;
724} 727}
725 728
@@ -937,7 +940,7 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
937 struct source_line *src_line = notes->src->lines; 940 struct source_line *src_line = notes->src->lines;
938 double percent = 0.0; 941 double percent = 0.0;
939 942
940 sample->nr_samples = 0; 943 sample->nr_samples = sample->period = 0;
941 944
942 if (src_line) { 945 if (src_line) {
943 size_t sizeof_src_line = sizeof(*src_line) + 946 size_t sizeof_src_line = sizeof(*src_line) +
@@ -957,11 +960,15 @@ double disasm__calc_percent(struct annotation *notes, int evidx, s64 offset,
957 } else { 960 } else {
958 struct sym_hist *h = annotation__histogram(notes, evidx); 961 struct sym_hist *h = annotation__histogram(notes, evidx);
959 unsigned int hits = 0; 962 unsigned int hits = 0;
963 u64 period = 0;
960 964
961 while (offset < end) 965 while (offset < end) {
962 hits += h->addr[offset++].nr_samples; 966 hits += h->addr[offset++].nr_samples;
967 period += h->addr[offset++].period;
968 }
963 969
964 if (h->nr_samples) { 970 if (h->nr_samples) {
971 sample->period = period;
965 sample->nr_samples = hits; 972 sample->nr_samples = hits;
966 percent = 100.0 * hits / h->nr_samples; 973 percent = 100.0 * hits / h->nr_samples;
967 } 974 }