aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/annotate.h
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2011-02-08 10:27:39 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2011-02-08 12:03:36 -0500
commitce6f4fab4059cd72638a0cfa596a8ee2c79c1c8e (patch)
tree00416d7a54d9ef265b9358022e804217dcb5d870 /tools/perf/util/annotate.h
parente3087b80aa0bceda9863f33307460f3ba79f2b15 (diff)
perf annotate: Move locking to struct annotation
Since we'll need it when implementing the live annotate TUI browser. This also simplifies things a bit by having the list head for the source code to be in the dynamicly allocated part of struct annotation, that way we don't have to pass it around, it can be found from the struct symbol that is passed everywhere. Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Tom Zanussi <tzanussi@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/annotate.h')
-rw-r--r--tools/perf/util/annotate.h34
1 files changed, 20 insertions, 14 deletions
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index bc08b36a713a..b237c8678c22 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -28,22 +28,29 @@ struct source_line {
28 char *path; 28 char *path;
29}; 29};
30 30
31/** struct annotation - symbols with hits have this attached as in sannotation 31/** struct annotated_source - symbols with hits have this attached as in sannotation
32 * 32 *
33 * @histogram: Array of addr hit histograms per event being monitored 33 * @histogram: Array of addr hit histograms per event being monitored
34 * @src_line: If 'print_lines' is specified, per source code line percentages 34 * @lines: If 'print_lines' is specified, per source code line percentages
35 * @source: source parsed from objdump -dS
35 * 36 *
36 * src_line is allocated, percentages calculated and all sorted by percentage 37 * lines is allocated, percentages calculated and all sorted by percentage
37 * when the annotation is about to be presented, so the percentages are for 38 * when the annotation is about to be presented, so the percentages are for
38 * one of the entries in the histogram array, i.e. for the event/counter being 39 * one of the entries in the histogram array, i.e. for the event/counter being
39 * presented. It is deallocated right after symbol__{tui,tty,etc}_annotate 40 * presented. It is deallocated right after symbol__{tui,tty,etc}_annotate
40 * returns. 41 * returns.
41 */ 42 */
42struct annotation { 43struct annotated_source {
43 struct source_line *src_line; 44 struct list_head source;
44 struct sym_hist *histograms; 45 struct source_line *lines;
45 int nr_histograms; 46 int nr_histograms;
46 int sizeof_sym_hist; 47 int sizeof_sym_hist;
48 struct sym_hist histograms[0];
49};
50
51struct annotation {
52 pthread_mutex_t lock;
53 struct annotated_source *src;
47}; 54};
48 55
49struct sannotation { 56struct sannotation {
@@ -53,7 +60,8 @@ struct sannotation {
53 60
54static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx) 61static inline struct sym_hist *annotation__histogram(struct annotation *notes, int idx)
55{ 62{
56 return ((void *)notes->histograms) + (notes->sizeof_sym_hist * idx); 63 return (((void *)&notes->src->histograms) +
64 (notes->src->sizeof_sym_hist * idx));
57} 65}
58 66
59static inline struct annotation *symbol__annotation(struct symbol *sym) 67static inline struct annotation *symbol__annotation(struct symbol *sym)
@@ -67,14 +75,12 @@ int symbol__inc_addr_samples(struct symbol *sym, struct map *map,
67int symbol__alloc_hist(struct symbol *sym, int nevents); 75int symbol__alloc_hist(struct symbol *sym, int nevents);
68void symbol__annotate_zero_histograms(struct symbol *sym); 76void symbol__annotate_zero_histograms(struct symbol *sym);
69 77
70int symbol__annotate(struct symbol *sym, struct map *map, 78int symbol__annotate(struct symbol *sym, struct map *map, size_t privsize);
71 struct list_head *head, size_t privsize); 79int symbol__annotate_init(struct map *map __used, struct symbol *sym);
72int symbol__annotate_printf(struct symbol *sym, struct map *map, 80int symbol__annotate_printf(struct symbol *sym, struct map *map, int evidx,
73 struct list_head *head, int evidx, bool full_paths, 81 bool full_paths, int min_pcnt, int max_lines);
74 int min_pcnt, int max_lines);
75void symbol__annotate_zero_histogram(struct symbol *sym, int evidx); 82void symbol__annotate_zero_histogram(struct symbol *sym, int evidx);
76void symbol__annotate_decay_histogram(struct symbol *sym, 83void symbol__annotate_decay_histogram(struct symbol *sym, int evidx);
77 struct list_head *head, int evidx);
78void objdump_line_list__purge(struct list_head *head); 84void objdump_line_list__purge(struct list_head *head);
79 85
80int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx, 86int symbol__tty_annotate(struct symbol *sym, struct map *map, int evidx,