aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2014-02-19 20:32:53 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-02-24 09:12:55 -0500
commit48c65bda95d692076de7e5eae3188ddae8635dca (patch)
treee1941e7c49e08c9b76f1065f68329947a802a74a /tools
parenta9d3f94ec7708427b9f05a65246d3fd6e287fa51 (diff)
perf annotate: Check availability of annotate when processing samples
The TUI of perf report and top support annotation, but stdio and GTK don't. So it should be checked before calling hist_entry__inc_addr_ samples() to avoid wasting resources that will never be used. perf annotate need it regardless of UI and sort keys, so the check of whether to allocate resources should be on the tools that have annotate as an option in the TUI, 'report' and 'top', not on the function called by all of them. It caused perf annotate on ppc64 to produce zero output, since the buckets were not being allocated. Reported-by: Anton Blanchard <anton@samba.org> Signed-off-by: Namhyung Kim <namhyung@kernel.org> Cc: Anton Blanchard <anton@samba.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung.kim@lge.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1392859976-32760-1-git-send-email-namhyung@kernel.org [ Renamed (report,top)__needs_annotate() to ui__has_annotation() ] Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-report.c40
-rw-r--r--tools/perf/builtin-top.c6
-rw-r--r--tools/perf/util/annotate.c9
-rw-r--r--tools/perf/util/annotate.h2
4 files changed, 38 insertions, 19 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 3c53ec268fbc..02f985f3a396 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -113,14 +113,16 @@ static int report__add_mem_hist_entry(struct perf_tool *tool, struct addr_locati
113 if (!he) 113 if (!he)
114 return -ENOMEM; 114 return -ENOMEM;
115 115
116 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 116 if (ui__has_annotation()) {
117 if (err) 117 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
118 goto out; 118 if (err)
119 goto out;
119 120
120 mx = he->mem_info; 121 mx = he->mem_info;
121 err = addr_map_symbol__inc_samples(&mx->daddr, evsel->idx); 122 err = addr_map_symbol__inc_samples(&mx->daddr, evsel->idx);
122 if (err) 123 if (err)
123 goto out; 124 goto out;
125 }
124 126
125 evsel->hists.stats.total_period += cost; 127 evsel->hists.stats.total_period += cost;
126 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); 128 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
@@ -164,14 +166,18 @@ static int report__add_branch_hist_entry(struct perf_tool *tool, struct addr_loc
164 he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL, 166 he = __hists__add_entry(&evsel->hists, al, parent, &bi[i], NULL,
165 1, 1, 0); 167 1, 1, 0);
166 if (he) { 168 if (he) {
167 bx = he->branch_info; 169 if (ui__has_annotation()) {
168 err = addr_map_symbol__inc_samples(&bx->from, evsel->idx); 170 bx = he->branch_info;
169 if (err) 171 err = addr_map_symbol__inc_samples(&bx->from,
170 goto out; 172 evsel->idx);
171 173 if (err)
172 err = addr_map_symbol__inc_samples(&bx->to, evsel->idx); 174 goto out;
173 if (err) 175
174 goto out; 176 err = addr_map_symbol__inc_samples(&bx->to,
177 evsel->idx);
178 if (err)
179 goto out;
180 }
175 181
176 evsel->hists.stats.total_period += 1; 182 evsel->hists.stats.total_period += 1;
177 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); 183 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
@@ -205,7 +211,9 @@ static int report__add_hist_entry(struct perf_tool *tool, struct perf_evsel *evs
205 if (err) 211 if (err)
206 goto out; 212 goto out;
207 213
208 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); 214 if (ui__has_annotation())
215 err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr);
216
209 evsel->hists.stats.total_period += sample->period; 217 evsel->hists.stats.total_period += sample->period;
210 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE); 218 hists__inc_nr_events(&evsel->hists, PERF_RECORD_SAMPLE);
211out: 219out:
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 76cd510d34d0..5f989a7d8bc2 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -176,7 +176,7 @@ static void perf_top__record_precise_ip(struct perf_top *top,
176{ 176{
177 struct annotation *notes; 177 struct annotation *notes;
178 struct symbol *sym; 178 struct symbol *sym;
179 int err; 179 int err = 0;
180 180
181 if (he == NULL || he->ms.sym == NULL || 181 if (he == NULL || he->ms.sym == NULL ||
182 ((top->sym_filter_entry == NULL || 182 ((top->sym_filter_entry == NULL ||
@@ -190,7 +190,9 @@ static void perf_top__record_precise_ip(struct perf_top *top,
190 return; 190 return;
191 191
192 ip = he->ms.map->map_ip(he->ms.map, ip); 192 ip = he->ms.map->map_ip(he->ms.map, ip);
193 err = hist_entry__inc_addr_samples(he, counter, ip); 193
194 if (ui__has_annotation())
195 err = hist_entry__inc_addr_samples(he, counter, ip);
194 196
195 pthread_mutex_unlock(&notes->lock); 197 pthread_mutex_unlock(&notes->lock);
196 198
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 469eb679fb9d..3aa555ff9d89 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -8,6 +8,8 @@
8 */ 8 */
9 9
10#include "util.h" 10#include "util.h"
11#include "ui/ui.h"
12#include "sort.h"
11#include "build-id.h" 13#include "build-id.h"
12#include "color.h" 14#include "color.h"
13#include "cache.h" 15#include "cache.h"
@@ -489,7 +491,7 @@ static int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
489{ 491{
490 struct annotation *notes; 492 struct annotation *notes;
491 493
492 if (sym == NULL || use_browser != 1 || !sort__has_sym) 494 if (sym == NULL)
493 return 0; 495 return 0;
494 496
495 notes = symbol__annotation(sym); 497 notes = symbol__annotation(sym);
@@ -1399,3 +1401,8 @@ int hist_entry__annotate(struct hist_entry *he, size_t privsize)
1399{ 1401{
1400 return symbol__annotate(he->ms.sym, he->ms.map, privsize); 1402 return symbol__annotate(he->ms.sym, he->ms.map, privsize);
1401} 1403}
1404
1405bool ui__has_annotation(void)
1406{
1407 return use_browser == 1 && sort__has_sym;
1408}
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index b2aef59d6bb2..56ad4f5287de 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -151,6 +151,8 @@ void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
151void symbol__annotate_decay_histogram(struct symbol *sym, int evidx); 151void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
152void disasm__purge(struct list_head *head); 152void disasm__purge(struct list_head *head);
153 153
154bool ui__has_annotation(void);
155
154int symbol__tty_annotate(struct symbol *sym, struct map *map, 156int symbol__tty_annotate(struct symbol *sym, struct map *map,
155 struct perf_evsel *evsel, bool print_lines, 157 struct perf_evsel *evsel, bool print_lines,
156 bool full_paths, int min_pcnt, int max_lines); 158 bool full_paths, int min_pcnt, int max_lines);