aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaeung Song <treeze.taeung@gmail.com>2017-07-20 15:28:53 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-07-21 07:23:50 -0400
commitbab89f6aed7e745893e009014354d0caaf62acf7 (patch)
treef1229f13ff462f6235b19850ed2822ec93891429
parent8158683da3d30e0346275702a8e08f2b22726c45 (diff)
perf hists: Pass perf_sample to __symbol__inc_addr_samples()
To pave the way to use perf_sample fields in the annotate code, storing sample->period in sym_hist->addr->period and its sum in sym_hist->period. Signed-off-by: Taeung Song <treeze.taeung@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1500500215-16646-1-git-send-email-treeze.taeung@gmail.com [ split and adjusted from a larger patch ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/builtin-annotate.c2
-rw-r--r--tools/perf/builtin-report.c15
-rw-r--r--tools/perf/builtin-top.c5
-rw-r--r--tools/perf/util/annotate.c18
-rw-r--r--tools/perf/util/annotate.h6
5 files changed, 27 insertions, 19 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 5205408e795b..96fe1a88c1e5 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -184,7 +184,7 @@ static int perf_evsel__add_sample(struct perf_evsel *evsel,
184 if (he == NULL) 184 if (he == NULL)
185 return -ENOMEM; 185 return -ENOMEM;
186 186
187 ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 187 ret = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
188 hists__inc_nr_samples(hists, true); 188 hists__inc_nr_samples(hists, true);
189 return ret; 189 return ret;
190} 190}
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index cea25d03f4dd..983b238d5eea 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -115,37 +115,38 @@ static int hist_iter__report_callback(struct hist_entry_iter *iter,
115 struct report *rep = arg; 115 struct report *rep = arg;
116 struct hist_entry *he = iter->he; 116 struct hist_entry *he = iter->he;
117 struct perf_evsel *evsel = iter->evsel; 117 struct perf_evsel *evsel = iter->evsel;
118 struct perf_sample *sample = iter->sample;
118 struct mem_info *mi; 119 struct mem_info *mi;
119 struct branch_info *bi; 120 struct branch_info *bi;
120 121
121 if (!ui__has_annotation()) 122 if (!ui__has_annotation())
122 return 0; 123 return 0;
123 124
124 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, 125 hist__account_cycles(sample->branch_stack, al, sample,
125 rep->nonany_branch_mode); 126 rep->nonany_branch_mode);
126 127
127 if (sort__mode == SORT_MODE__BRANCH) { 128 if (sort__mode == SORT_MODE__BRANCH) {
128 bi = he->branch_info; 129 bi = he->branch_info;
129 err = addr_map_symbol__inc_samples(&bi->from, evsel->idx); 130 err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx);
130 if (err) 131 if (err)
131 goto out; 132 goto out;
132 133
133 err = addr_map_symbol__inc_samples(&bi->to, evsel->idx); 134 err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx);
134 135
135 } else if (rep->mem_mode) { 136 } else if (rep->mem_mode) {
136 mi = he->mem_info; 137 mi = he->mem_info;
137 err = addr_map_symbol__inc_samples(&mi->daddr, evsel->idx); 138 err = addr_map_symbol__inc_samples(&mi->daddr, sample, evsel->idx);
138 if (err) 139 if (err)
139 goto out; 140 goto out;
140 141
141 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 142 err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
142 143
143 } else if (symbol_conf.cumulate_callchain) { 144 } else if (symbol_conf.cumulate_callchain) {
144 if (single) 145 if (single)
145 err = hist_entry__inc_addr_samples(he, evsel->idx, 146 err = hist_entry__inc_addr_samples(he, sample, evsel->idx,
146 al->addr); 147 al->addr);
147 } else { 148 } else {
148 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 149 err = hist_entry__inc_addr_samples(he, sample, evsel->idx, al->addr);
149 } 150 }
150 151
151out: 152out:
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 022486dc67f5..e5a8f249077f 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -183,6 +183,7 @@ static void ui__warn_map_erange(struct map *map, struct symbol *sym, u64 ip)
183 183
184static void perf_top__record_precise_ip(struct perf_top *top, 184static void perf_top__record_precise_ip(struct perf_top *top,
185 struct hist_entry *he, 185 struct hist_entry *he,
186 struct perf_sample *sample,
186 int counter, u64 ip) 187 int counter, u64 ip)
187{ 188{
188 struct annotation *notes; 189 struct annotation *notes;
@@ -199,7 +200,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,
199 if (pthread_mutex_trylock(&notes->lock)) 200 if (pthread_mutex_trylock(&notes->lock))
200 return; 201 return;
201 202
202 err = hist_entry__inc_addr_samples(he, counter, ip); 203 err = hist_entry__inc_addr_samples(he, sample, counter, ip);
203 204
204 pthread_mutex_unlock(&notes->lock); 205 pthread_mutex_unlock(&notes->lock);
205 206
@@ -671,7 +672,7 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,
671 struct perf_evsel *evsel = iter->evsel; 672 struct perf_evsel *evsel = iter->evsel;
672 673
673 if (perf_hpp_list.sym && single) 674 if (perf_hpp_list.sym && single)
674 perf_top__record_precise_ip(top, he, evsel->idx, al->addr); 675 perf_top__record_precise_ip(top, he, iter->sample, evsel->idx, al->addr);
675 676
676 hist__account_cycles(iter->sample->branch_stack, al, iter->sample, 677 hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
677 !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY)); 678 !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY));
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 58c6b63ff049..c2fe16d5e473 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -697,7 +697,8 @@ static int __symbol__account_cycles(struct annotation *notes,
697} 697}
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{ 702{
702 unsigned offset; 703 unsigned offset;
703 struct sym_hist *h; 704 struct sym_hist *h;
@@ -738,7 +739,8 @@ static struct annotation *symbol__get_annotation(struct symbol *sym, bool cycles
738} 739}
739 740
740static int symbol__inc_addr_samples(struct symbol *sym, struct map *map, 741static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
741 int evidx, u64 addr) 742 int evidx, u64 addr,
743 struct perf_sample *sample)
742{ 744{
743 struct annotation *notes; 745 struct annotation *notes;
744 746
@@ -747,7 +749,7 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
747 notes = symbol__get_annotation(sym, false); 749 notes = symbol__get_annotation(sym, false);
748 if (notes == NULL) 750 if (notes == NULL)
749 return -ENOMEM; 751 return -ENOMEM;
750 return __symbol__inc_addr_samples(sym, map, notes, evidx, addr); 752 return __symbol__inc_addr_samples(sym, map, notes, evidx, addr, sample);
751} 753}
752 754
753static int symbol__account_cycles(u64 addr, u64 start, 755static int symbol__account_cycles(u64 addr, u64 start,
@@ -811,14 +813,16 @@ int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
811 return err; 813 return err;
812} 814}
813 815
814int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, int evidx) 816int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
817 int evidx)
815{ 818{
816 return symbol__inc_addr_samples(ams->sym, ams->map, evidx, ams->al_addr); 819 return symbol__inc_addr_samples(ams->sym, ams->map, evidx, ams->al_addr, sample);
817} 820}
818 821
819int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 ip) 822int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
823 int evidx, u64 ip)
820{ 824{
821 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip); 825 return symbol__inc_addr_samples(he->ms.sym, he->ms.map, evidx, ip, sample);
822} 826}
823 827
824static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map *map) 828static void disasm_line__init_ins(struct disasm_line *dl, struct arch *arch, struct map *map)
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index e8c246ec53df..720f18195046 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -154,13 +154,15 @@ static inline struct annotation *symbol__annotation(struct symbol *sym)
154 return (void *)sym - symbol_conf.priv_size; 154 return (void *)sym - symbol_conf.priv_size;
155} 155}
156 156
157int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, int evidx); 157int addr_map_symbol__inc_samples(struct addr_map_symbol *ams, struct perf_sample *sample,
158 int evidx);
158 159
159int addr_map_symbol__account_cycles(struct addr_map_symbol *ams, 160int addr_map_symbol__account_cycles(struct addr_map_symbol *ams,
160 struct addr_map_symbol *start, 161 struct addr_map_symbol *start,
161 unsigned cycles); 162 unsigned cycles);
162 163
163int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr); 164int hist_entry__inc_addr_samples(struct hist_entry *he, struct perf_sample *sample,
165 int evidx, u64 addr);
164 166
165int symbol__alloc_hist(struct symbol *sym); 167int symbol__alloc_hist(struct symbol *sym);
166void symbol__annotate_zero_histograms(struct symbol *sym); 168void symbol__annotate_zero_histograms(struct symbol *sym);