diff options
-rw-r--r-- | tools/perf/builtin-annotate.c | 22 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 7 | ||||
-rw-r--r-- | tools/perf/util/annotate.c | 6 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 5 | ||||
-rw-r--r-- | tools/perf/util/header.c | 2 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 3 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 1 | ||||
-rw-r--r-- | tools/perf/util/ui/browsers/annotate.c | 16 | ||||
-rw-r--r-- | tools/perf/util/ui/browsers/hists.c | 2 |
10 files changed, 30 insertions, 37 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 46b4c24f338e..8b9091bce98d 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -43,10 +43,9 @@ static const char *sym_hist_filter; | |||
43 | static const char *cpu_list; | 43 | static const char *cpu_list; |
44 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | 44 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
45 | 45 | ||
46 | static int perf_evlist__add_sample(struct perf_evlist *evlist, | 46 | static int perf_evsel__add_sample(struct perf_evsel *evsel, |
47 | struct perf_sample *sample, | 47 | struct perf_sample *sample, |
48 | struct perf_evsel *evsel, | 48 | struct addr_location *al) |
49 | struct addr_location *al) | ||
50 | { | 49 | { |
51 | struct hist_entry *he; | 50 | struct hist_entry *he; |
52 | int ret; | 51 | int ret; |
@@ -69,8 +68,7 @@ static int perf_evlist__add_sample(struct perf_evlist *evlist, | |||
69 | ret = 0; | 68 | ret = 0; |
70 | if (he->ms.sym != NULL) { | 69 | if (he->ms.sym != NULL) { |
71 | struct annotation *notes = symbol__annotation(he->ms.sym); | 70 | struct annotation *notes = symbol__annotation(he->ms.sym); |
72 | if (notes->src == NULL && | 71 | if (notes->src == NULL && symbol__alloc_hist(he->ms.sym) < 0) |
73 | symbol__alloc_hist(he->ms.sym, evlist->nr_entries) < 0) | ||
74 | return -ENOMEM; | 72 | return -ENOMEM; |
75 | 73 | ||
76 | ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); | 74 | ret = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); |
@@ -98,8 +96,7 @@ static int process_sample_event(union perf_event *event, | |||
98 | if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) | 96 | if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) |
99 | return 0; | 97 | return 0; |
100 | 98 | ||
101 | if (!al.filtered && | 99 | if (!al.filtered && perf_evsel__add_sample(evsel, sample, &al)) { |
102 | perf_evlist__add_sample(session->evlist, sample, evsel, &al)) { | ||
103 | pr_warning("problem incrementing symbol count, " | 100 | pr_warning("problem incrementing symbol count, " |
104 | "skipping event\n"); | 101 | "skipping event\n"); |
105 | return -1; | 102 | return -1; |
@@ -114,8 +111,7 @@ static int hist_entry__tty_annotate(struct hist_entry *he, int evidx) | |||
114 | print_line, full_paths, 0, 0); | 111 | print_line, full_paths, 0, 0); |
115 | } | 112 | } |
116 | 113 | ||
117 | static void hists__find_annotations(struct hists *self, int evidx, | 114 | static void hists__find_annotations(struct hists *self, int evidx) |
118 | int nr_events) | ||
119 | { | 115 | { |
120 | struct rb_node *nd = rb_first(&self->entries), *next; | 116 | struct rb_node *nd = rb_first(&self->entries), *next; |
121 | int key = K_RIGHT; | 117 | int key = K_RIGHT; |
@@ -138,8 +134,7 @@ find_next: | |||
138 | } | 134 | } |
139 | 135 | ||
140 | if (use_browser > 0) { | 136 | if (use_browser > 0) { |
141 | key = hist_entry__tui_annotate(he, evidx, nr_events, | 137 | key = hist_entry__tui_annotate(he, evidx, NULL, NULL, 0); |
142 | NULL, NULL, 0); | ||
143 | switch (key) { | 138 | switch (key) { |
144 | case K_RIGHT: | 139 | case K_RIGHT: |
145 | next = rb_next(nd); | 140 | next = rb_next(nd); |
@@ -217,8 +212,7 @@ static int __cmd_annotate(void) | |||
217 | total_nr_samples += nr_samples; | 212 | total_nr_samples += nr_samples; |
218 | hists__collapse_resort(hists); | 213 | hists__collapse_resort(hists); |
219 | hists__output_resort(hists); | 214 | hists__output_resort(hists); |
220 | hists__find_annotations(hists, pos->idx, | 215 | hists__find_annotations(hists, pos->idx); |
221 | session->evlist->nr_entries); | ||
222 | } | 216 | } |
223 | } | 217 | } |
224 | 218 | ||
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 4d7c8340c326..758a287fc07a 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -92,8 +92,7 @@ static int perf_session__add_hist_entry(struct perf_session *session, | |||
92 | assert(evsel != NULL); | 92 | assert(evsel != NULL); |
93 | 93 | ||
94 | err = -ENOMEM; | 94 | err = -ENOMEM; |
95 | if (notes->src == NULL && | 95 | if (notes->src == NULL && symbol__alloc_hist(he->ms.sym) < 0) |
96 | symbol__alloc_hist(he->ms.sym, session->evlist->nr_entries) < 0) | ||
97 | goto out; | 96 | goto out; |
98 | 97 | ||
99 | err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); | 98 | err = hist_entry__inc_addr_samples(he, evsel->idx, al->addr); |
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index c9cdedb58134..04288ee223ed 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -170,7 +170,7 @@ static int parse_source(struct hist_entry *he) | |||
170 | 170 | ||
171 | pthread_mutex_lock(¬es->lock); | 171 | pthread_mutex_lock(¬es->lock); |
172 | 172 | ||
173 | if (symbol__alloc_hist(sym, top.evlist->nr_entries) < 0) { | 173 | if (symbol__alloc_hist(sym) < 0) { |
174 | pthread_mutex_unlock(¬es->lock); | 174 | pthread_mutex_unlock(¬es->lock); |
175 | pr_err("Not enough memory for annotating '%s' symbol!\n", | 175 | pr_err("Not enough memory for annotating '%s' symbol!\n", |
176 | sym->name); | 176 | sym->name); |
@@ -210,8 +210,7 @@ static void record_precise_ip(struct hist_entry *he, int counter, u64 ip) | |||
210 | if (pthread_mutex_trylock(¬es->lock)) | 210 | if (pthread_mutex_trylock(¬es->lock)) |
211 | return; | 211 | return; |
212 | 212 | ||
213 | if (notes->src == NULL && | 213 | if (notes->src == NULL && symbol__alloc_hist(sym) < 0) { |
214 | symbol__alloc_hist(sym, top.evlist->nr_entries) < 0) { | ||
215 | pthread_mutex_unlock(¬es->lock); | 214 | pthread_mutex_unlock(¬es->lock); |
216 | pr_err("Not enough memory for annotating '%s' symbol!\n", | 215 | pr_err("Not enough memory for annotating '%s' symbol!\n", |
217 | sym->name); | 216 | sym->name); |
@@ -1215,6 +1214,8 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1215 | return -ENOMEM; | 1214 | return -ENOMEM; |
1216 | } | 1215 | } |
1217 | 1216 | ||
1217 | symbol_conf.nr_events = top.evlist->nr_entries; | ||
1218 | |||
1218 | if (top.delay_secs < 1) | 1219 | if (top.delay_secs < 1) |
1219 | top.delay_secs = 1; | 1220 | top.delay_secs = 1; |
1220 | 1221 | ||
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 119e996035c8..376e643f7066 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c | |||
@@ -25,17 +25,17 @@ int symbol__annotate_init(struct map *map __used, struct symbol *sym) | |||
25 | return 0; | 25 | return 0; |
26 | } | 26 | } |
27 | 27 | ||
28 | int symbol__alloc_hist(struct symbol *sym, int nevents) | 28 | int symbol__alloc_hist(struct symbol *sym) |
29 | { | 29 | { |
30 | struct annotation *notes = symbol__annotation(sym); | 30 | struct annotation *notes = symbol__annotation(sym); |
31 | size_t sizeof_sym_hist = (sizeof(struct sym_hist) + | 31 | size_t sizeof_sym_hist = (sizeof(struct sym_hist) + |
32 | (sym->end - sym->start) * sizeof(u64)); | 32 | (sym->end - sym->start) * sizeof(u64)); |
33 | 33 | ||
34 | notes->src = zalloc(sizeof(*notes->src) + nevents * sizeof_sym_hist); | 34 | notes->src = zalloc(sizeof(*notes->src) + symbol_conf.nr_events * sizeof_sym_hist); |
35 | if (notes->src == NULL) | 35 | if (notes->src == NULL) |
36 | return -1; | 36 | return -1; |
37 | notes->src->sizeof_sym_hist = sizeof_sym_hist; | 37 | notes->src->sizeof_sym_hist = sizeof_sym_hist; |
38 | notes->src->nr_histograms = nevents; | 38 | notes->src->nr_histograms = symbol_conf.nr_events; |
39 | INIT_LIST_HEAD(¬es->src->source); | 39 | INIT_LIST_HEAD(¬es->src->source); |
40 | return 0; | 40 | return 0; |
41 | } | 41 | } |
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index d9072523d342..efa5dc82bfae 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h | |||
@@ -72,7 +72,7 @@ static inline struct annotation *symbol__annotation(struct symbol *sym) | |||
72 | 72 | ||
73 | int symbol__inc_addr_samples(struct symbol *sym, struct map *map, | 73 | int symbol__inc_addr_samples(struct symbol *sym, struct map *map, |
74 | int evidx, u64 addr); | 74 | int evidx, u64 addr); |
75 | int symbol__alloc_hist(struct symbol *sym, int nevents); | 75 | int symbol__alloc_hist(struct symbol *sym); |
76 | void symbol__annotate_zero_histograms(struct symbol *sym); | 76 | void symbol__annotate_zero_histograms(struct symbol *sym); |
77 | 77 | ||
78 | int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize); | 78 | int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize); |
@@ -99,8 +99,7 @@ static inline int symbol__tui_annotate(struct symbol *sym __used, | |||
99 | } | 99 | } |
100 | #else | 100 | #else |
101 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | 101 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, |
102 | int nr_events, void(*timer)(void *arg), void *arg, | 102 | void(*timer)(void *arg), void *arg, int delay_secs); |
103 | int delay_secs); | ||
104 | #endif | 103 | #endif |
105 | 104 | ||
106 | extern const char *disassembler_style; | 105 | extern const char *disassembler_style; |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index bcd05d05b4f0..41424a16be8e 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -2041,6 +2041,8 @@ int perf_session__read_header(struct perf_session *session, int fd) | |||
2041 | lseek(fd, tmp, SEEK_SET); | 2041 | lseek(fd, tmp, SEEK_SET); |
2042 | } | 2042 | } |
2043 | 2043 | ||
2044 | symbol_conf.nr_events = nr_attrs; | ||
2045 | |||
2044 | if (f_header.event_types.size) { | 2046 | if (f_header.event_types.size) { |
2045 | lseek(fd, f_header.event_types.offset, SEEK_SET); | 2047 | lseek(fd, f_header.event_types.offset, SEEK_SET); |
2046 | events = malloc(f_header.event_types.size); | 2048 | events = malloc(f_header.event_types.size); |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index c86c1d27bd1e..6676d558b2a7 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -119,7 +119,6 @@ int perf_evlist__tui_browse_hists(struct perf_evlist *evlist __used, | |||
119 | 119 | ||
120 | static inline int hist_entry__tui_annotate(struct hist_entry *self __used, | 120 | static inline int hist_entry__tui_annotate(struct hist_entry *self __used, |
121 | int evidx __used, | 121 | int evidx __used, |
122 | int nr_events __used, | ||
123 | void(*timer)(void *arg) __used, | 122 | void(*timer)(void *arg) __used, |
124 | void *arg __used, | 123 | void *arg __used, |
125 | int delay_secs __used) | 124 | int delay_secs __used) |
@@ -130,7 +129,7 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self __used, | |||
130 | #define K_RIGHT -2 | 129 | #define K_RIGHT -2 |
131 | #else | 130 | #else |
132 | #include "ui/keysyms.h" | 131 | #include "ui/keysyms.h" |
133 | int hist_entry__tui_annotate(struct hist_entry *he, int evidx, int nr_events, | 132 | int hist_entry__tui_annotate(struct hist_entry *he, int evidx, |
134 | void(*timer)(void *arg), void *arg, int delay_secs); | 133 | void(*timer)(void *arg), void *arg, int delay_secs); |
135 | 134 | ||
136 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, | 135 | int perf_evlist__tui_browse_hists(struct perf_evlist *evlist, const char *help, |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 29f8d742e92f..123c2e14353e 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -68,6 +68,7 @@ struct strlist; | |||
68 | 68 | ||
69 | struct symbol_conf { | 69 | struct symbol_conf { |
70 | unsigned short priv_size; | 70 | unsigned short priv_size; |
71 | unsigned short nr_events; | ||
71 | bool try_vmlinux_path, | 72 | bool try_vmlinux_path, |
72 | use_modules, | 73 | use_modules, |
73 | sort_by_name, | 74 | sort_by_name, |
diff --git a/tools/perf/util/ui/browsers/annotate.c b/tools/perf/util/ui/browsers/annotate.c index 0575905d1205..295a9c93f945 100644 --- a/tools/perf/util/ui/browsers/annotate.c +++ b/tools/perf/util/ui/browsers/annotate.c | |||
@@ -224,7 +224,7 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser) | |||
224 | } | 224 | } |
225 | 225 | ||
226 | static int annotate_browser__run(struct annotate_browser *self, int evidx, | 226 | static int annotate_browser__run(struct annotate_browser *self, int evidx, |
227 | int nr_events, void(*timer)(void *arg), | 227 | void(*timer)(void *arg), |
228 | void *arg, int delay_secs) | 228 | void *arg, int delay_secs) |
229 | { | 229 | { |
230 | struct rb_node *nd = NULL; | 230 | struct rb_node *nd = NULL; |
@@ -328,8 +328,7 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, | |||
328 | notes = symbol__annotation(target); | 328 | notes = symbol__annotation(target); |
329 | pthread_mutex_lock(¬es->lock); | 329 | pthread_mutex_lock(¬es->lock); |
330 | 330 | ||
331 | if (notes->src == NULL && | 331 | if (notes->src == NULL && symbol__alloc_hist(target) < 0) { |
332 | symbol__alloc_hist(target, nr_events) < 0) { | ||
333 | pthread_mutex_unlock(¬es->lock); | 332 | pthread_mutex_unlock(¬es->lock); |
334 | ui__warning("Not enough memory for annotating '%s' symbol!\n", | 333 | ui__warning("Not enough memory for annotating '%s' symbol!\n", |
335 | target->name); | 334 | target->name); |
@@ -337,7 +336,7 @@ static int annotate_browser__run(struct annotate_browser *self, int evidx, | |||
337 | } | 336 | } |
338 | 337 | ||
339 | pthread_mutex_unlock(¬es->lock); | 338 | pthread_mutex_unlock(¬es->lock); |
340 | symbol__tui_annotate(target, ms->map, evidx, nr_events, | 339 | symbol__tui_annotate(target, ms->map, evidx, |
341 | timer, arg, delay_secs); | 340 | timer, arg, delay_secs); |
342 | } | 341 | } |
343 | continue; | 342 | continue; |
@@ -358,15 +357,15 @@ out: | |||
358 | return key; | 357 | return key; |
359 | } | 358 | } |
360 | 359 | ||
361 | int hist_entry__tui_annotate(struct hist_entry *he, int evidx, int nr_events, | 360 | int hist_entry__tui_annotate(struct hist_entry *he, int evidx, |
362 | void(*timer)(void *arg), void *arg, int delay_secs) | 361 | void(*timer)(void *arg), void *arg, int delay_secs) |
363 | { | 362 | { |
364 | return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, nr_events, | 363 | return symbol__tui_annotate(he->ms.sym, he->ms.map, evidx, |
365 | timer, arg, delay_secs); | 364 | timer, arg, delay_secs); |
366 | } | 365 | } |
367 | 366 | ||
368 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | 367 | int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, |
369 | int nr_events, void(*timer)(void *arg), void *arg, | 368 | void(*timer)(void *arg), void *arg, |
370 | int delay_secs) | 369 | int delay_secs) |
371 | { | 370 | { |
372 | struct objdump_line *pos, *n; | 371 | struct objdump_line *pos, *n; |
@@ -419,8 +418,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx, | |||
419 | browser.b.nr_entries = browser.nr_entries; | 418 | browser.b.nr_entries = browser.nr_entries; |
420 | browser.b.entries = ¬es->src->source, | 419 | browser.b.entries = ¬es->src->source, |
421 | browser.b.width += 18; /* Percentage */ | 420 | browser.b.width += 18; /* Percentage */ |
422 | ret = annotate_browser__run(&browser, evidx, nr_events, | 421 | ret = annotate_browser__run(&browser, evidx, timer, arg, delay_secs); |
423 | timer, arg, delay_secs); | ||
424 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { | 422 | list_for_each_entry_safe(pos, n, ¬es->src->source, node) { |
425 | list_del(&pos->node); | 423 | list_del(&pos->node); |
426 | objdump_line__free(pos); | 424 | objdump_line__free(pos); |
diff --git a/tools/perf/util/ui/browsers/hists.c b/tools/perf/util/ui/browsers/hists.c index d0c94b459685..1212a386a033 100644 --- a/tools/perf/util/ui/browsers/hists.c +++ b/tools/perf/util/ui/browsers/hists.c | |||
@@ -1020,7 +1020,7 @@ do_annotate: | |||
1020 | * Don't let this be freed, say, by hists__decay_entry. | 1020 | * Don't let this be freed, say, by hists__decay_entry. |
1021 | */ | 1021 | */ |
1022 | he->used = true; | 1022 | he->used = true; |
1023 | err = hist_entry__tui_annotate(he, evsel->idx, nr_events, | 1023 | err = hist_entry__tui_annotate(he, evsel->idx, |
1024 | timer, arg, delay_secs); | 1024 | timer, arg, delay_secs); |
1025 | he->used = false; | 1025 | he->used = false; |
1026 | ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); | 1026 | ui_browser__update_nr_entries(&browser->b, browser->hists->nr_entries); |