diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-10-30 14:28:24 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-11-02 10:52:11 -0500 |
commit | 00a192b395b0606ad0265243844b3cd68e73420a (patch) | |
tree | 09149f550807c365f170c857b1021d66e5bb8b4b /tools/perf | |
parent | afb7b4f08e274cecd8337f9444affa288a9cd4c1 (diff) |
perf tools: Simplify the symbol priv area mechanism
Before we were storing this in the DSO, but in fact this is a
property of the 'symbol' class, not something that will vary
among DSOs, so move it to a global variable and initialize it
using the existing symbol__init routine.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Mike Galbraith <efault@gmx.de>
LKML-Reference: <1256927305-4628-2-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/builtin-annotate.c | 21 | ||||
-rw-r--r-- | tools/perf/builtin-report.c | 4 | ||||
-rw-r--r-- | tools/perf/builtin-sched.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-timechart.c | 2 | ||||
-rw-r--r-- | tools/perf/builtin-top.c | 12 | ||||
-rw-r--r-- | tools/perf/builtin-trace.c | 2 | ||||
-rw-r--r-- | tools/perf/util/data_map.c | 2 | ||||
-rw-r--r-- | tools/perf/util/event.h | 3 | ||||
-rw-r--r-- | tools/perf/util/map.c | 5 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 73 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 24 |
11 files changed, 70 insertions, 80 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 8688bfee42ab..77d50a6d6802 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c | |||
@@ -55,11 +55,11 @@ struct sym_priv { | |||
55 | 55 | ||
56 | static const char *sym_hist_filter; | 56 | static const char *sym_hist_filter; |
57 | 57 | ||
58 | static int symbol_filter(struct map *map, struct symbol *sym) | 58 | static int symbol_filter(struct map *map __used, struct symbol *sym) |
59 | { | 59 | { |
60 | if (sym_hist_filter == NULL || | 60 | if (sym_hist_filter == NULL || |
61 | strcmp(sym->name, sym_hist_filter) == 0) { | 61 | strcmp(sym->name, sym_hist_filter) == 0) { |
62 | struct sym_priv *priv = dso__sym_priv(map->dso, sym); | 62 | struct sym_priv *priv = symbol__priv(sym); |
63 | const int size = (sizeof(*priv->hist) + | 63 | const int size = (sizeof(*priv->hist) + |
64 | (sym->end - sym->start) * sizeof(u64)); | 64 | (sym->end - sym->start) * sizeof(u64)); |
65 | 65 | ||
@@ -92,7 +92,7 @@ static void hist_hit(struct hist_entry *he, u64 ip) | |||
92 | if (!sym || !he->map) | 92 | if (!sym || !he->map) |
93 | return; | 93 | return; |
94 | 94 | ||
95 | priv = dso__sym_priv(he->map->dso, sym); | 95 | priv = symbol__priv(sym); |
96 | if (!priv->hist) | 96 | if (!priv->hist) |
97 | return; | 97 | return; |
98 | 98 | ||
@@ -202,8 +202,7 @@ got_map: | |||
202 | static int | 202 | static int |
203 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | 203 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) |
204 | { | 204 | { |
205 | struct map *map = map__new(&event->mmap, NULL, 0, | 205 | struct map *map = map__new(&event->mmap, NULL, 0); |
206 | sizeof(struct sym_priv)); | ||
207 | struct thread *thread = threads__findnew(event->mmap.pid); | 206 | struct thread *thread = threads__findnew(event->mmap.pid); |
208 | 207 | ||
209 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n", | 208 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d: [%p(%p) @ %p]: %s\n", |
@@ -355,7 +354,7 @@ static int parse_line(FILE *file, struct hist_entry *he, u64 len) | |||
355 | unsigned int hits = 0; | 354 | unsigned int hits = 0; |
356 | double percent = 0.0; | 355 | double percent = 0.0; |
357 | const char *color; | 356 | const char *color; |
358 | struct sym_priv *priv = dso__sym_priv(he->map->dso, sym); | 357 | struct sym_priv *priv = symbol__priv(sym); |
359 | struct sym_ext *sym_ext = priv->ext; | 358 | struct sym_ext *sym_ext = priv->ext; |
360 | struct sym_hist *h = priv->hist; | 359 | struct sym_hist *h = priv->hist; |
361 | 360 | ||
@@ -422,7 +421,7 @@ static void insert_source_line(struct sym_ext *sym_ext) | |||
422 | 421 | ||
423 | static void free_source_line(struct hist_entry *he, int len) | 422 | static void free_source_line(struct hist_entry *he, int len) |
424 | { | 423 | { |
425 | struct sym_priv *priv = dso__sym_priv(he->map->dso, he->sym); | 424 | struct sym_priv *priv = symbol__priv(he->sym); |
426 | struct sym_ext *sym_ext = priv->ext; | 425 | struct sym_ext *sym_ext = priv->ext; |
427 | int i; | 426 | int i; |
428 | 427 | ||
@@ -446,7 +445,7 @@ get_source_line(struct hist_entry *he, int len, const char *filename) | |||
446 | int i; | 445 | int i; |
447 | char cmd[PATH_MAX * 2]; | 446 | char cmd[PATH_MAX * 2]; |
448 | struct sym_ext *sym_ext; | 447 | struct sym_ext *sym_ext; |
449 | struct sym_priv *priv = dso__sym_priv(he->map->dso, sym); | 448 | struct sym_priv *priv = symbol__priv(sym); |
450 | struct sym_hist *h = priv->hist; | 449 | struct sym_hist *h = priv->hist; |
451 | 450 | ||
452 | if (!h->sum) | 451 | if (!h->sum) |
@@ -589,7 +588,7 @@ static void find_annotations(void) | |||
589 | if (he->sym == NULL) | 588 | if (he->sym == NULL) |
590 | continue; | 589 | continue; |
591 | 590 | ||
592 | priv = dso__sym_priv(he->map->dso, he->sym); | 591 | priv = symbol__priv(he->sym); |
593 | if (priv->hist == NULL) | 592 | if (priv->hist == NULL) |
594 | continue; | 593 | continue; |
595 | 594 | ||
@@ -637,7 +636,7 @@ static int __cmd_annotate(void) | |||
637 | exit(0); | 636 | exit(0); |
638 | } | 637 | } |
639 | 638 | ||
640 | if (load_kernel(sizeof(struct sym_priv), symbol_filter) < 0) { | 639 | if (load_kernel(symbol_filter) < 0) { |
641 | perror("failed to load kernel symbols"); | 640 | perror("failed to load kernel symbols"); |
642 | return EXIT_FAILURE; | 641 | return EXIT_FAILURE; |
643 | } | 642 | } |
@@ -769,7 +768,7 @@ static void setup_sorting(void) | |||
769 | 768 | ||
770 | int cmd_annotate(int argc, const char **argv, const char *prefix __used) | 769 | int cmd_annotate(int argc, const char **argv, const char *prefix __used) |
771 | { | 770 | { |
772 | symbol__init(); | 771 | symbol__init(sizeof(struct sym_priv)); |
773 | 772 | ||
774 | page_size = getpagesize(); | 773 | page_size = getpagesize(); |
775 | 774 | ||
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index f1bcd35bd220..1a806d5f05cf 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
@@ -751,7 +751,7 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head) | |||
751 | static int | 751 | static int |
752 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) | 752 | process_mmap_event(event_t *event, unsigned long offset, unsigned long head) |
753 | { | 753 | { |
754 | struct map *map = map__new(&event->mmap, cwd, cwdlen, 0); | 754 | struct map *map = map__new(&event->mmap, cwd, cwdlen); |
755 | struct thread *thread = threads__findnew(event->mmap.pid); | 755 | struct thread *thread = threads__findnew(event->mmap.pid); |
756 | 756 | ||
757 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n", | 757 | dump_printf("%p [%p]: PERF_RECORD_MMAP %d/%d: [%p(%p) @ %p]: %s\n", |
@@ -1093,7 +1093,7 @@ static void setup_list(struct strlist **list, const char *list_str, | |||
1093 | 1093 | ||
1094 | int cmd_report(int argc, const char **argv, const char *prefix __used) | 1094 | int cmd_report(int argc, const char **argv, const char *prefix __used) |
1095 | { | 1095 | { |
1096 | symbol__init(); | 1096 | symbol__init(0); |
1097 | 1097 | ||
1098 | argc = parse_options(argc, argv, options, report_usage, 0); | 1098 | argc = parse_options(argc, argv, options, report_usage, 0); |
1099 | 1099 | ||
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c index 9a48d9626be4..df44b756cecc 100644 --- a/tools/perf/builtin-sched.c +++ b/tools/perf/builtin-sched.c | |||
@@ -1937,7 +1937,7 @@ static int __cmd_record(int argc, const char **argv) | |||
1937 | 1937 | ||
1938 | int cmd_sched(int argc, const char **argv, const char *prefix __used) | 1938 | int cmd_sched(int argc, const char **argv, const char *prefix __used) |
1939 | { | 1939 | { |
1940 | symbol__init(); | 1940 | symbol__init(0); |
1941 | 1941 | ||
1942 | argc = parse_options(argc, argv, sched_options, sched_usage, | 1942 | argc = parse_options(argc, argv, sched_options, sched_usage, |
1943 | PARSE_OPT_STOP_AT_NON_OPTION); | 1943 | PARSE_OPT_STOP_AT_NON_OPTION); |
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c index 0a2f22261c3a..665877e4a944 100644 --- a/tools/perf/builtin-timechart.c +++ b/tools/perf/builtin-timechart.c | |||
@@ -1266,7 +1266,7 @@ static const struct option options[] = { | |||
1266 | 1266 | ||
1267 | int cmd_timechart(int argc, const char **argv, const char *prefix __used) | 1267 | int cmd_timechart(int argc, const char **argv, const char *prefix __used) |
1268 | { | 1268 | { |
1269 | symbol__init(); | 1269 | symbol__init(0); |
1270 | 1270 | ||
1271 | page_size = getpagesize(); | 1271 | page_size = getpagesize(); |
1272 | 1272 | ||
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index ee87640b3359..2aea913f7eb7 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -789,7 +789,7 @@ static int symbol_filter(struct map *map, struct symbol *sym) | |||
789 | strstr(name, "_text_end")) | 789 | strstr(name, "_text_end")) |
790 | return 1; | 790 | return 1; |
791 | 791 | ||
792 | syme = dso__sym_priv(map->dso, sym); | 792 | syme = symbol__priv(sym); |
793 | syme->map = map; | 793 | syme->map = map; |
794 | pthread_mutex_init(&syme->source_lock, NULL); | 794 | pthread_mutex_init(&syme->source_lock, NULL); |
795 | if (!sym_filter_entry && sym_filter && !strcmp(name, sym_filter)) | 795 | if (!sym_filter_entry && sym_filter && !strcmp(name, sym_filter)) |
@@ -807,8 +807,7 @@ static int symbol_filter(struct map *map, struct symbol *sym) | |||
807 | 807 | ||
808 | static int parse_symbols(void) | 808 | static int parse_symbols(void) |
809 | { | 809 | { |
810 | if (dsos__load_kernel(vmlinux_name, sizeof(struct sym_entry), | 810 | if (dsos__load_kernel(vmlinux_name, symbol_filter, 1) <= 0) |
811 | symbol_filter, 1) <= 0) | ||
812 | return -1; | 811 | return -1; |
813 | 812 | ||
814 | if (dump_symtab) | 813 | if (dump_symtab) |
@@ -859,7 +858,7 @@ static void event__process_sample(const event_t *self, int counter) | |||
859 | return; | 858 | return; |
860 | } | 859 | } |
861 | 860 | ||
862 | syme = dso__sym_priv(map->dso, sym); | 861 | syme = symbol__priv(sym); |
863 | 862 | ||
864 | if (!syme->skip) { | 863 | if (!syme->skip) { |
865 | syme->count[counter]++; | 864 | syme->count[counter]++; |
@@ -878,8 +877,7 @@ static void event__process_mmap(event_t *self) | |||
878 | struct thread *thread = threads__findnew(self->mmap.pid); | 877 | struct thread *thread = threads__findnew(self->mmap.pid); |
879 | 878 | ||
880 | if (thread != NULL) { | 879 | if (thread != NULL) { |
881 | struct map *map = map__new(&self->mmap, NULL, 0, | 880 | struct map *map = map__new(&self->mmap, NULL, 0); |
882 | sizeof(struct sym_entry)); | ||
883 | if (map != NULL) | 881 | if (map != NULL) |
884 | thread__insert_map(thread, map); | 882 | thread__insert_map(thread, map); |
885 | } | 883 | } |
@@ -1176,7 +1174,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used) | |||
1176 | { | 1174 | { |
1177 | int counter; | 1175 | int counter; |
1178 | 1176 | ||
1179 | symbol__init(); | 1177 | symbol__init(sizeof(struct sym_entry)); |
1180 | 1178 | ||
1181 | page_size = sysconf(_SC_PAGE_SIZE); | 1179 | page_size = sysconf(_SC_PAGE_SIZE); |
1182 | 1180 | ||
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index e566bbe3f22d..d042d656c561 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -151,7 +151,7 @@ static const struct option options[] = { | |||
151 | 151 | ||
152 | int cmd_trace(int argc, const char **argv, const char *prefix __used) | 152 | int cmd_trace(int argc, const char **argv, const char *prefix __used) |
153 | { | 153 | { |
154 | symbol__init(); | 154 | symbol__init(0); |
155 | 155 | ||
156 | argc = parse_options(argc, argv, options, annotate_usage, 0); | 156 | argc = parse_options(argc, argv, options, annotate_usage, 0); |
157 | if (argc) { | 157 | if (argc) { |
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c index 18accb8fee4d..c458db9ede6d 100644 --- a/tools/perf/util/data_map.c +++ b/tools/perf/util/data_map.c | |||
@@ -130,7 +130,7 @@ int mmap_dispatch_perf_file(struct perf_header **pheader, | |||
130 | if (curr_handler->sample_type_check(sample_type) < 0) | 130 | if (curr_handler->sample_type_check(sample_type) < 0) |
131 | exit(-1); | 131 | exit(-1); |
132 | 132 | ||
133 | if (load_kernel(0, NULL) < 0) { | 133 | if (load_kernel(NULL) < 0) { |
134 | perror("failed to load kernel symbols"); | 134 | perror("failed to load kernel symbols"); |
135 | return EXIT_FAILURE; | 135 | return EXIT_FAILURE; |
136 | } | 136 | } |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 4a158a01bb97..0a443bea68db 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -107,8 +107,7 @@ typedef int (*symbol_filter_t)(struct map *map, struct symbol *sym); | |||
107 | 107 | ||
108 | void map__init(struct map *self, u64 start, u64 end, u64 pgoff, | 108 | void map__init(struct map *self, u64 start, u64 end, u64 pgoff, |
109 | struct dso *dso); | 109 | struct dso *dso); |
110 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | 110 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen); |
111 | unsigned int sym_priv_size); | ||
112 | struct map *map__clone(struct map *self); | 111 | struct map *map__clone(struct map *self); |
113 | int map__overlap(struct map *l, struct map *r); | 112 | int map__overlap(struct map *l, struct map *r); |
114 | size_t map__fprintf(struct map *self, FILE *fp); | 113 | size_t map__fprintf(struct map *self, FILE *fp); |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index 3b7ce1bf9f8e..679011c1b6d1 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -32,8 +32,7 @@ void map__init(struct map *self, u64 start, u64 end, u64 pgoff, | |||
32 | RB_CLEAR_NODE(&self->rb_node); | 32 | RB_CLEAR_NODE(&self->rb_node); |
33 | } | 33 | } |
34 | 34 | ||
35 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | 35 | struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen) |
36 | unsigned int sym_priv_size) | ||
37 | { | 36 | { |
38 | struct map *self = malloc(sizeof(*self)); | 37 | struct map *self = malloc(sizeof(*self)); |
39 | 38 | ||
@@ -60,7 +59,7 @@ struct map *map__new(struct mmap_event *event, char *cwd, int cwdlen, | |||
60 | filename = newfilename; | 59 | filename = newfilename; |
61 | } | 60 | } |
62 | 61 | ||
63 | dso = dsos__findnew(filename, sym_priv_size); | 62 | dso = dsos__findnew(filename); |
64 | if (dso == NULL) | 63 | if (dso == NULL) |
65 | goto out_delete; | 64 | goto out_delete; |
66 | 65 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 13677b5dbe5e..cf2c7f778868 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -26,6 +26,7 @@ static void dsos__add(struct dso *dso); | |||
26 | static struct dso *dsos__find(const char *name); | 26 | static struct dso *dsos__find(const char *name); |
27 | static struct map *map__new2(u64 start, struct dso *dso); | 27 | static struct map *map__new2(u64 start, struct dso *dso); |
28 | static void kernel_maps__insert(struct map *map); | 28 | static void kernel_maps__insert(struct map *map); |
29 | unsigned int symbol__priv_size; | ||
29 | 30 | ||
30 | static struct rb_root kernel_maps; | 31 | static struct rb_root kernel_maps; |
31 | 32 | ||
@@ -75,18 +76,17 @@ static void kernel_maps__fixup_end(void) | |||
75 | } | 76 | } |
76 | } | 77 | } |
77 | 78 | ||
78 | static struct symbol *symbol__new(u64 start, u64 len, const char *name, | 79 | static struct symbol *symbol__new(u64 start, u64 len, const char *name) |
79 | unsigned int priv_size) | ||
80 | { | 80 | { |
81 | size_t namelen = strlen(name) + 1; | 81 | size_t namelen = strlen(name) + 1; |
82 | struct symbol *self = calloc(1, priv_size + sizeof(*self) + namelen); | 82 | struct symbol *self = calloc(1, (symbol__priv_size + |
83 | 83 | sizeof(*self) + namelen)); | |
84 | if (!self) | 84 | if (!self) |
85 | return NULL; | 85 | return NULL; |
86 | 86 | ||
87 | if (priv_size) { | 87 | if (symbol__priv_size) { |
88 | memset(self, 0, priv_size); | 88 | memset(self, 0, symbol__priv_size); |
89 | self = ((void *)self) + priv_size; | 89 | self = ((void *)self) + symbol__priv_size; |
90 | } | 90 | } |
91 | self->start = start; | 91 | self->start = start; |
92 | self->end = len ? start + len - 1 : start; | 92 | self->end = len ? start + len - 1 : start; |
@@ -98,9 +98,9 @@ static struct symbol *symbol__new(u64 start, u64 len, const char *name, | |||
98 | return self; | 98 | return self; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void symbol__delete(struct symbol *self, unsigned int priv_size) | 101 | static void symbol__delete(struct symbol *self) |
102 | { | 102 | { |
103 | free(((void *)self) - priv_size); | 103 | free(((void *)self) - symbol__priv_size); |
104 | } | 104 | } |
105 | 105 | ||
106 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) | 106 | static size_t symbol__fprintf(struct symbol *self, FILE *fp) |
@@ -109,7 +109,7 @@ static size_t symbol__fprintf(struct symbol *self, FILE *fp) | |||
109 | self->start, self->end, self->name); | 109 | self->start, self->end, self->name); |
110 | } | 110 | } |
111 | 111 | ||
112 | struct dso *dso__new(const char *name, unsigned int sym_priv_size) | 112 | struct dso *dso__new(const char *name) |
113 | { | 113 | { |
114 | struct dso *self = malloc(sizeof(*self) + strlen(name) + 1); | 114 | struct dso *self = malloc(sizeof(*self) + strlen(name) + 1); |
115 | 115 | ||
@@ -118,7 +118,6 @@ struct dso *dso__new(const char *name, unsigned int sym_priv_size) | |||
118 | self->long_name = self->name; | 118 | self->long_name = self->name; |
119 | self->short_name = self->name; | 119 | self->short_name = self->name; |
120 | self->syms = RB_ROOT; | 120 | self->syms = RB_ROOT; |
121 | self->sym_priv_size = sym_priv_size; | ||
122 | self->find_symbol = dso__find_symbol; | 121 | self->find_symbol = dso__find_symbol; |
123 | self->slen_calculated = 0; | 122 | self->slen_calculated = 0; |
124 | self->origin = DSO__ORIG_NOT_FOUND; | 123 | self->origin = DSO__ORIG_NOT_FOUND; |
@@ -136,7 +135,7 @@ static void dso__delete_symbols(struct dso *self) | |||
136 | pos = rb_entry(next, struct symbol, rb_node); | 135 | pos = rb_entry(next, struct symbol, rb_node); |
137 | next = rb_next(&pos->rb_node); | 136 | next = rb_next(&pos->rb_node); |
138 | rb_erase(&pos->rb_node, &self->syms); | 137 | rb_erase(&pos->rb_node, &self->syms); |
139 | symbol__delete(pos, self->sym_priv_size); | 138 | symbol__delete(pos); |
140 | } | 139 | } |
141 | } | 140 | } |
142 | 141 | ||
@@ -250,8 +249,7 @@ static int kernel_maps__load_all_kallsyms(void) | |||
250 | /* | 249 | /* |
251 | * Will fix up the end later, when we have all symbols sorted. | 250 | * Will fix up the end later, when we have all symbols sorted. |
252 | */ | 251 | */ |
253 | sym = symbol__new(start, 0, symbol_name, | 252 | sym = symbol__new(start, 0, symbol_name); |
254 | kernel_map->dso->sym_priv_size); | ||
255 | 253 | ||
256 | if (sym == NULL) | 254 | if (sym == NULL) |
257 | goto out_delete_line; | 255 | goto out_delete_line; |
@@ -317,8 +315,7 @@ static int kernel_maps__split_kallsyms(symbol_filter_t filter, int use_modules) | |||
317 | snprintf(dso_name, sizeof(dso_name), "[kernel].%d", | 315 | snprintf(dso_name, sizeof(dso_name), "[kernel].%d", |
318 | kernel_range++); | 316 | kernel_range++); |
319 | 317 | ||
320 | dso = dso__new(dso_name, | 318 | dso = dso__new(dso_name); |
321 | kernel_map->dso->sym_priv_size); | ||
322 | if (dso == NULL) | 319 | if (dso == NULL) |
323 | return -1; | 320 | return -1; |
324 | 321 | ||
@@ -336,7 +333,7 @@ static int kernel_maps__split_kallsyms(symbol_filter_t filter, int use_modules) | |||
336 | if (filter && filter(map, pos)) { | 333 | if (filter && filter(map, pos)) { |
337 | delete_symbol: | 334 | delete_symbol: |
338 | rb_erase(&pos->rb_node, &kernel_map->dso->syms); | 335 | rb_erase(&pos->rb_node, &kernel_map->dso->syms); |
339 | symbol__delete(pos, kernel_map->dso->sym_priv_size); | 336 | symbol__delete(pos); |
340 | } else { | 337 | } else { |
341 | if (map != kernel_map) { | 338 | if (map != kernel_map) { |
342 | rb_erase(&pos->rb_node, &kernel_map->dso->syms); | 339 | rb_erase(&pos->rb_node, &kernel_map->dso->syms); |
@@ -417,14 +414,13 @@ static int dso__load_perf_map(struct dso *self, struct map *map, | |||
417 | if (len + 2 >= line_len) | 414 | if (len + 2 >= line_len) |
418 | continue; | 415 | continue; |
419 | 416 | ||
420 | sym = symbol__new(start, size, line + len, | 417 | sym = symbol__new(start, size, line + len); |
421 | self->sym_priv_size); | ||
422 | 418 | ||
423 | if (sym == NULL) | 419 | if (sym == NULL) |
424 | goto out_delete_line; | 420 | goto out_delete_line; |
425 | 421 | ||
426 | if (filter && filter(map, sym)) | 422 | if (filter && filter(map, sym)) |
427 | symbol__delete(sym, self->sym_priv_size); | 423 | symbol__delete(sym); |
428 | else { | 424 | else { |
429 | dso__insert_symbol(self, sym); | 425 | dso__insert_symbol(self, sym); |
430 | nr_syms++; | 426 | nr_syms++; |
@@ -616,7 +612,7 @@ static int dso__synthesize_plt_symbols(struct dso *self) | |||
616 | "%s@plt", elf_sym__name(&sym, symstrs)); | 612 | "%s@plt", elf_sym__name(&sym, symstrs)); |
617 | 613 | ||
618 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, | 614 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, |
619 | sympltname, self->sym_priv_size); | 615 | sympltname); |
620 | if (!f) | 616 | if (!f) |
621 | goto out_elf_end; | 617 | goto out_elf_end; |
622 | 618 | ||
@@ -634,7 +630,7 @@ static int dso__synthesize_plt_symbols(struct dso *self) | |||
634 | "%s@plt", elf_sym__name(&sym, symstrs)); | 630 | "%s@plt", elf_sym__name(&sym, symstrs)); |
635 | 631 | ||
636 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, | 632 | f = symbol__new(plt_offset, shdr_plt.sh_entsize, |
637 | sympltname, self->sym_priv_size); | 633 | sympltname); |
638 | if (!f) | 634 | if (!f) |
639 | goto out_elf_end; | 635 | goto out_elf_end; |
640 | 636 | ||
@@ -769,7 +765,7 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
769 | if (kmodule) | 765 | if (kmodule) |
770 | start += map->start + shdr.sh_offset; | 766 | start += map->start + shdr.sh_offset; |
771 | 767 | ||
772 | curr_dso = dso__new(dso_name, self->sym_priv_size); | 768 | curr_dso = dso__new(dso_name); |
773 | if (curr_dso == NULL) | 769 | if (curr_dso == NULL) |
774 | goto out_elf_end; | 770 | goto out_elf_end; |
775 | curr_map = map__new2(start, curr_dso); | 771 | curr_map = map__new2(start, curr_dso); |
@@ -803,14 +799,13 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, | |||
803 | if (demangled != NULL) | 799 | if (demangled != NULL) |
804 | elf_name = demangled; | 800 | elf_name = demangled; |
805 | new_symbol: | 801 | new_symbol: |
806 | f = symbol__new(sym.st_value, sym.st_size, elf_name, | 802 | f = symbol__new(sym.st_value, sym.st_size, elf_name); |
807 | curr_dso->sym_priv_size); | ||
808 | free(demangled); | 803 | free(demangled); |
809 | if (!f) | 804 | if (!f) |
810 | goto out_elf_end; | 805 | goto out_elf_end; |
811 | 806 | ||
812 | if (filter && filter(curr_map, f)) | 807 | if (filter && filter(curr_map, f)) |
813 | symbol__delete(f, curr_dso->sym_priv_size); | 808 | symbol__delete(f); |
814 | else { | 809 | else { |
815 | dso__insert_symbol(curr_dso, f); | 810 | dso__insert_symbol(curr_dso, f); |
816 | nr++; | 811 | nr++; |
@@ -1141,7 +1136,7 @@ static struct map *map__new2(u64 start, struct dso *dso) | |||
1141 | return self; | 1136 | return self; |
1142 | } | 1137 | } |
1143 | 1138 | ||
1144 | static int dsos__load_modules(unsigned int sym_priv_size) | 1139 | static int dsos__load_modules(void) |
1145 | { | 1140 | { |
1146 | char *line = NULL; | 1141 | char *line = NULL; |
1147 | size_t n; | 1142 | size_t n; |
@@ -1180,7 +1175,7 @@ static int dsos__load_modules(unsigned int sym_priv_size) | |||
1180 | *sep = '\0'; | 1175 | *sep = '\0'; |
1181 | 1176 | ||
1182 | snprintf(name, sizeof(name), "[%s]", line); | 1177 | snprintf(name, sizeof(name), "[%s]", line); |
1183 | dso = dso__new(name, sym_priv_size); | 1178 | dso = dso__new(name); |
1184 | 1179 | ||
1185 | if (dso == NULL) | 1180 | if (dso == NULL) |
1186 | goto out_delete_line; | 1181 | goto out_delete_line; |
@@ -1224,11 +1219,11 @@ static int dso__load_vmlinux(struct dso *self, struct map *map, | |||
1224 | return err; | 1219 | return err; |
1225 | } | 1220 | } |
1226 | 1221 | ||
1227 | int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, | 1222 | int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, |
1228 | symbol_filter_t filter, int use_modules) | 1223 | int use_modules) |
1229 | { | 1224 | { |
1230 | int err = -1; | 1225 | int err = -1; |
1231 | struct dso *dso = dso__new(vmlinux, sym_priv_size); | 1226 | struct dso *dso = dso__new(vmlinux); |
1232 | 1227 | ||
1233 | if (dso == NULL) | 1228 | if (dso == NULL) |
1234 | return -1; | 1229 | return -1; |
@@ -1240,7 +1235,7 @@ int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, | |||
1240 | 1235 | ||
1241 | kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip; | 1236 | kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip; |
1242 | 1237 | ||
1243 | if (use_modules && dsos__load_modules(sym_priv_size) < 0) { | 1238 | if (use_modules && dsos__load_modules() < 0) { |
1244 | pr_warning("Failed to load list of modules in use! " | 1239 | pr_warning("Failed to load list of modules in use! " |
1245 | "Continuing...\n"); | 1240 | "Continuing...\n"); |
1246 | use_modules = 0; | 1241 | use_modules = 0; |
@@ -1312,12 +1307,12 @@ static struct dso *dsos__find(const char *name) | |||
1312 | return NULL; | 1307 | return NULL; |
1313 | } | 1308 | } |
1314 | 1309 | ||
1315 | struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size) | 1310 | struct dso *dsos__findnew(const char *name) |
1316 | { | 1311 | { |
1317 | struct dso *dso = dsos__find(name); | 1312 | struct dso *dso = dsos__find(name); |
1318 | 1313 | ||
1319 | if (!dso) { | 1314 | if (!dso) { |
1320 | dso = dso__new(name, sym_priv_size); | 1315 | dso = dso__new(name); |
1321 | if (dso != NULL) | 1316 | if (dso != NULL) |
1322 | dsos__add(dso); | 1317 | dsos__add(dso); |
1323 | } | 1318 | } |
@@ -1333,13 +1328,12 @@ void dsos__fprintf(FILE *fp) | |||
1333 | dso__fprintf(pos, fp); | 1328 | dso__fprintf(pos, fp); |
1334 | } | 1329 | } |
1335 | 1330 | ||
1336 | int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter) | 1331 | int load_kernel(symbol_filter_t filter) |
1337 | { | 1332 | { |
1338 | if (dsos__load_kernel(vmlinux_name, sym_priv_size, filter, | 1333 | if (dsos__load_kernel(vmlinux_name, filter, modules) <= 0) |
1339 | modules) <= 0) | ||
1340 | return -1; | 1334 | return -1; |
1341 | 1335 | ||
1342 | vdso = dso__new("[vdso]", 0); | 1336 | vdso = dso__new("[vdso]"); |
1343 | if (!vdso) | 1337 | if (!vdso) |
1344 | return -1; | 1338 | return -1; |
1345 | 1339 | ||
@@ -1348,7 +1342,8 @@ int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter) | |||
1348 | return 0; | 1342 | return 0; |
1349 | } | 1343 | } |
1350 | 1344 | ||
1351 | void symbol__init(void) | 1345 | void symbol__init(unsigned int priv_size) |
1352 | { | 1346 | { |
1353 | elf_version(EV_CURRENT); | 1347 | elf_version(EV_CURRENT); |
1348 | symbol__priv_size = priv_size; | ||
1354 | } | 1349 | } |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 432edbca7806..a471a3840736 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -39,11 +39,17 @@ struct symbol { | |||
39 | char name[0]; | 39 | char name[0]; |
40 | }; | 40 | }; |
41 | 41 | ||
42 | extern unsigned int symbol__priv_size; | ||
43 | |||
44 | static inline void *symbol__priv(struct symbol *self) | ||
45 | { | ||
46 | return ((void *)self) - symbol__priv_size; | ||
47 | } | ||
48 | |||
42 | struct dso { | 49 | struct dso { |
43 | struct list_head node; | 50 | struct list_head node; |
44 | struct rb_root syms; | 51 | struct rb_root syms; |
45 | struct symbol *(*find_symbol)(struct dso *, u64 ip); | 52 | struct symbol *(*find_symbol)(struct dso *, u64 ip); |
46 | unsigned int sym_priv_size; | ||
47 | unsigned char adjust_symbols; | 53 | unsigned char adjust_symbols; |
48 | unsigned char slen_calculated; | 54 | unsigned char slen_calculated; |
49 | bool loaded; | 55 | bool loaded; |
@@ -53,28 +59,22 @@ struct dso { | |||
53 | char name[0]; | 59 | char name[0]; |
54 | }; | 60 | }; |
55 | 61 | ||
56 | struct dso *dso__new(const char *name, unsigned int sym_priv_size); | 62 | struct dso *dso__new(const char *name); |
57 | void dso__delete(struct dso *self); | 63 | void dso__delete(struct dso *self); |
58 | 64 | ||
59 | static inline void *dso__sym_priv(struct dso *self, struct symbol *sym) | ||
60 | { | ||
61 | return ((void *)sym) - self->sym_priv_size; | ||
62 | } | ||
63 | |||
64 | struct symbol *dso__find_symbol(struct dso *self, u64 ip); | 65 | struct symbol *dso__find_symbol(struct dso *self, u64 ip); |
65 | 66 | ||
66 | int dsos__load_kernel(const char *vmlinux, unsigned int sym_priv_size, | 67 | int dsos__load_kernel(const char *vmlinux, symbol_filter_t filter, int modules); |
67 | symbol_filter_t filter, int modules); | 68 | struct dso *dsos__findnew(const char *name); |
68 | struct dso *dsos__findnew(const char *name, unsigned int sym_priv_size); | ||
69 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); | 69 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); |
70 | void dsos__fprintf(FILE *fp); | 70 | void dsos__fprintf(FILE *fp); |
71 | 71 | ||
72 | size_t dso__fprintf(struct dso *self, FILE *fp); | 72 | size_t dso__fprintf(struct dso *self, FILE *fp); |
73 | char dso__symtab_origin(const struct dso *self); | 73 | char dso__symtab_origin(const struct dso *self); |
74 | 74 | ||
75 | int load_kernel(unsigned int sym_priv_size, symbol_filter_t filter); | 75 | int load_kernel(symbol_filter_t filter); |
76 | 76 | ||
77 | void symbol__init(void); | 77 | void symbol__init(unsigned int priv_size); |
78 | 78 | ||
79 | extern struct list_head dsos; | 79 | extern struct list_head dsos; |
80 | extern struct map *kernel_map; | 80 | extern struct map *kernel_map; |