perf annotate: Introduce struct sym_hist_entry
PATCH v3 1/9 perf annotate: Introduce struct sym_hist_entry
struct sym_hist has addr[] but it should have not only number of samples but also the sample period. So use new struct symhist_entry for that.
Cc Namhyung Kim <[email protected]>
Cc Jiri Olsa <[email protected]>
Signed-off-by Taeung Song <[email protected]>
--- tools/perf/ui/browsers/annotate.c | 6 +++--- tools/perf/ui/gtk/annotate.c | 4 ++-- tools/perf/util/annotate.c | 45 ++++++++++++++++++++------------------- tools/perf/util/annotate.h | 9 ++++++-- 4 files changed, 35 insertions(+), 29 deletions(-)
tools/perf/ui/browsers/annotate.c +3 -3
@@ -449,14 +449,14 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, next =disasm__get_next_ip_line (¬es->src->source, pos);for (i =0 ; i < browser->nr_events; i++) { -u64 nr_samples; +struct sym_hist_entry sample; bpos->samples[i].percent =disasm__calc_percent (notes, evsel->idx + i, pos->offset, next ? next->offset : len, - &path, &nr_samples); - bpos->samples[i].nr = nr_samples; + &path, &sample); + bpos->samples[i].nr = sample.nr_samples;if (max_percent < bpos->samples[i].percent) max_percent = bpos->samples[i].percent;
tools/perf/ui/gtk/annotate.c +2 -2
@@ -34,10 +34,10 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym,return 0 ; symhist =annotation__histogram (symbol__annotation (sym), evidx); -if (!symbol_conf.event_group && !symhist->addr[dl->offset]) +if (!symbol_conf.event_group && !symhist->addr[dl->offset].nr_samples)return 0 ; - percent =100.0 * symhist->addr[dl->offset] / symhist->sum; + percent =100.0 * symhist->addr[dl->offset].nr_samples / symhist->sum; markup =perf_gtk__get_percent_color (percent);if (markup)
tools/perf/util/annotate.c +23 -22
142 lines not on this page · raw message
tools/perf/util/annotate.h +7 -2
@@ -74,16 +74,21 @@ static inline bool disasm_line__has_offset(const struct disasm_line *dl)return dl->ops.target.offset_avail; } +struct sym_hist_entry { +u64 nr_samples; +u64 period; +}; +void disasm_line__free (struct disasm_line *dl);struct disasm_line *disasm__get_next_ip_line (struct list_head *head,struct disasm_line *pos);int disasm_line__scnprintf (struct disasm_line *dl,char *bf,size_t size,bool raw);size_t disasm__fprintf (struct list_head *head,FILE *fp);double disasm__calc_percent (struct annotation *notes,int evidx,s64 offset, -s64 end,const char **path,u64 *nr_samples); +s64 end,const char **path,struct sym_hist_entry *sample);struct sym_hist {u64 sum; -u64 addr[0 ]; +struct sym_hist_entry addr[0 ]; };struct cyc_hist {
Signature · 1 line
2.7.4
tip-bot for Taeung Song
merge botperf annotate: Introduce struct sym_hist_entry
Commit-ID: 896bccd3cb8d95cbc565687715516009c5169e71 Gitweb: http://git.kernel.org/tip/896bccd3cb8d95cbc565687715516009c5169e71 Author: Taeung Song <[email protected]> AuthorDate: Thu, 20 Jul 2017 06:36:45 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 21 Jul 2017 08:23:38 -0300
perf annotate: Introduce struct sym_hist_entry
struct sym_hist has addr[] but it should have not only number of samples but also the sample period. So use new struct symhist_entry to pave the way to have that.
Committer notes:
This initial patch will only introduce the struct sym_hist_entry and use only the nr_samples member, which makes the code clearer and paves the way to save the period as well.
Signed-off-by Taeung Song <[email protected]>
Suggested-by Arnaldo Carvalho de Melo <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/perf/ui/browsers/annotate.c | 6 +++--- tools/perf/ui/gtk/annotate.c | 4 ++-- tools/perf/util/annotate.c | 45 ++++++++++++++++++++------------------- tools/perf/util/annotate.h | 9 ++++++-- 4 files changed, 35 insertions(+), 29 deletions(-)
tools/perf/ui/browsers/annotate.c +3 -3
@@ -450,14 +450,14 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser, next =disasm__get_next_ip_line (¬es->src->source, pos);for (i =0 ; i < browser->nr_events; i++) { -u64 nr_samples; +struct sym_hist_entry sample; bpos->samples[i].percent =disasm__calc_percent (notes, evsel->idx + i, pos->offset, next ? next->offset : len, - &path, &nr_samples); - bpos->samples[i].nr = nr_samples; + &path, &sample); + bpos->samples[i].nr = sample.nr_samples;if (max_percent < bpos->samples[i].percent) max_percent = bpos->samples[i].percent;
tools/perf/ui/gtk/annotate.c +2 -2
@@ -34,10 +34,10 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym,return 0 ; symhist =annotation__histogram (symbol__annotation (sym), evidx); -if (!symbol_conf.event_group && !symhist->addr[dl->offset]) +if (!symbol_conf.event_group && !symhist->addr[dl->offset].nr_samples)return 0 ; - percent =100.0 * symhist->addr[dl->offset] / symhist->sum; + percent =100.0 * symhist->addr[dl->offset].nr_samples / symhist->sum; markup =perf_gtk__get_percent_color (percent);if (markup)
tools/perf/util/annotate.c +23 -22
142 lines not on this page · raw message
tools/perf/util/annotate.h +7 -2
@@ -74,16 +74,21 @@ static inline bool disasm_line__has_offset(const struct disasm_line *dl)return dl->ops.target.offset_avail; } +struct sym_hist_entry { +u64 nr_samples; +u64 period; +}; +void disasm_line__free (struct disasm_line *dl);struct disasm_line *disasm__get_next_ip_line (struct list_head *head,struct disasm_line *pos);int disasm_line__scnprintf (struct disasm_line *dl,char *bf,size_t size,bool raw);size_t disasm__fprintf (struct list_head *head,FILE *fp);double disasm__calc_percent (struct annotation *notes,int evidx,s64 offset, -s64 end,const char **path,u64 *nr_samples); +s64 end,const char **path,struct sym_hist_entry *sample);struct sym_hist {u64 sum; -u64 addr[0 ]; +struct sym_hist_entry addr[0 ]; };struct cyc_hist {