diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-01-27 07:44:29 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-06 08:00:38 -0500 |
commit | 41f30914fc33116cfd0fd0982c8effe435d97698 (patch) | |
tree | 205c38e17e6b81c56950906d56dcf13daeb71596 | |
parent | 1101f69af5335a863765100d1df1999fd1e8c5bf (diff) |
perf map: Move structs and prototypes for map groups to a separate header
And since machine.h only needs what is in there, make it stop including
map.h and instead include this newly introduced map_groups.h instead.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-dbob25fv5rp2rjpwlnterf38@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/arch/arm/tests/dwarf-unwind.c | 1 | ||||
-rw-r--r-- | tools/perf/arch/arm64/tests/dwarf-unwind.c | 1 | ||||
-rw-r--r-- | tools/perf/arch/powerpc/tests/dwarf-unwind.c | 1 | ||||
-rw-r--r-- | tools/perf/arch/x86/tests/dwarf-unwind.c | 1 | ||||
-rw-r--r-- | tools/perf/ui/stdio/hist.c | 1 | ||||
-rw-r--r-- | tools/perf/util/machine.h | 2 | ||||
-rw-r--r-- | tools/perf/util/map.c | 6 | ||||
-rw-r--r-- | tools/perf/util/map.h | 87 | ||||
-rw-r--r-- | tools/perf/util/map_groups.h | 91 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 1 | ||||
-rw-r--r-- | tools/perf/util/symbol-elf.c | 1 |
11 files changed, 106 insertions, 87 deletions
diff --git a/tools/perf/arch/arm/tests/dwarf-unwind.c b/tools/perf/arch/arm/tests/dwarf-unwind.c index 9a0242e74cfc..2c35e532bc9a 100644 --- a/tools/perf/arch/arm/tests/dwarf-unwind.c +++ b/tools/perf/arch/arm/tests/dwarf-unwind.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "perf_regs.h" | 3 | #include "perf_regs.h" |
4 | #include "thread.h" | 4 | #include "thread.h" |
5 | #include "map.h" | 5 | #include "map.h" |
6 | #include "map_groups.h" | ||
6 | #include "event.h" | 7 | #include "event.h" |
7 | #include "debug.h" | 8 | #include "debug.h" |
8 | #include "tests/tests.h" | 9 | #include "tests/tests.h" |
diff --git a/tools/perf/arch/arm64/tests/dwarf-unwind.c b/tools/perf/arch/arm64/tests/dwarf-unwind.c index 5522ce384723..a6a407fa1b8b 100644 --- a/tools/perf/arch/arm64/tests/dwarf-unwind.c +++ b/tools/perf/arch/arm64/tests/dwarf-unwind.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "perf_regs.h" | 3 | #include "perf_regs.h" |
4 | #include "thread.h" | 4 | #include "thread.h" |
5 | #include "map.h" | 5 | #include "map.h" |
6 | #include "map_groups.h" | ||
6 | #include "event.h" | 7 | #include "event.h" |
7 | #include "debug.h" | 8 | #include "debug.h" |
8 | #include "tests/tests.h" | 9 | #include "tests/tests.h" |
diff --git a/tools/perf/arch/powerpc/tests/dwarf-unwind.c b/tools/perf/arch/powerpc/tests/dwarf-unwind.c index 5f39efef0856..5c178e4a1995 100644 --- a/tools/perf/arch/powerpc/tests/dwarf-unwind.c +++ b/tools/perf/arch/powerpc/tests/dwarf-unwind.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "perf_regs.h" | 3 | #include "perf_regs.h" |
4 | #include "thread.h" | 4 | #include "thread.h" |
5 | #include "map.h" | 5 | #include "map.h" |
6 | #include "map_groups.h" | ||
6 | #include "event.h" | 7 | #include "event.h" |
7 | #include "debug.h" | 8 | #include "debug.h" |
8 | #include "tests/tests.h" | 9 | #include "tests/tests.h" |
diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c index 7879df34569a..6ad0a1cedb13 100644 --- a/tools/perf/arch/x86/tests/dwarf-unwind.c +++ b/tools/perf/arch/x86/tests/dwarf-unwind.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "perf_regs.h" | 3 | #include "perf_regs.h" |
4 | #include "thread.h" | 4 | #include "thread.h" |
5 | #include "map.h" | 5 | #include "map.h" |
6 | #include "map_groups.h" | ||
6 | #include "event.h" | 7 | #include "event.h" |
7 | #include "debug.h" | 8 | #include "debug.h" |
8 | #include "tests/tests.h" | 9 | #include "tests/tests.h" |
diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 814abf5e9a5c..bb653a47f47a 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "../../util/util.h" | 5 | #include "../../util/util.h" |
6 | #include "../../util/hist.h" | 6 | #include "../../util/hist.h" |
7 | #include "../../util/map.h" | 7 | #include "../../util/map.h" |
8 | #include "../../util/map_groups.h" | ||
8 | #include "../../util/sort.h" | 9 | #include "../../util/sort.h" |
9 | #include "../../util/evsel.h" | 10 | #include "../../util/evsel.h" |
10 | #include "../../util/srcline.h" | 11 | #include "../../util/srcline.h" |
diff --git a/tools/perf/util/machine.h b/tools/perf/util/machine.h index e2f3df45410a..f70ab98a7bde 100644 --- a/tools/perf/util/machine.h +++ b/tools/perf/util/machine.h | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | #include <sys/types.h> | 5 | #include <sys/types.h> |
6 | #include <linux/rbtree.h> | 6 | #include <linux/rbtree.h> |
7 | #include "map.h" | 7 | #include "map_groups.h" |
8 | #include "dso.h" | 8 | #include "dso.h" |
9 | #include "event.h" | 9 | #include "event.h" |
10 | #include "rwsem.h" | 10 | #include "rwsem.h" |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index cf407cc9d915..fbeb0c6efaa6 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
@@ -557,6 +557,12 @@ void map_groups__init(struct map_groups *mg, struct machine *machine) | |||
557 | refcount_set(&mg->refcnt, 1); | 557 | refcount_set(&mg->refcnt, 1); |
558 | } | 558 | } |
559 | 559 | ||
560 | void map_groups__insert(struct map_groups *mg, struct map *map) | ||
561 | { | ||
562 | maps__insert(&mg->maps, map); | ||
563 | map->groups = mg; | ||
564 | } | ||
565 | |||
560 | static void __maps__purge(struct maps *maps) | 566 | static void __maps__purge(struct maps *maps) |
561 | { | 567 | { |
562 | struct rb_root *root = &maps->entries; | 568 | struct rb_root *root = &maps->entries; |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 5a889db4fca5..0e20749f2c55 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
@@ -6,12 +6,10 @@ | |||
6 | #include <linux/compiler.h> | 6 | #include <linux/compiler.h> |
7 | #include <linux/list.h> | 7 | #include <linux/list.h> |
8 | #include <linux/rbtree.h> | 8 | #include <linux/rbtree.h> |
9 | #include <pthread.h> | ||
10 | #include <stdio.h> | 9 | #include <stdio.h> |
11 | #include <string.h> | 10 | #include <string.h> |
12 | #include <stdbool.h> | 11 | #include <stdbool.h> |
13 | #include <linux/types.h> | 12 | #include <linux/types.h> |
14 | #include "rwsem.h" | ||
15 | 13 | ||
16 | struct dso; | 14 | struct dso; |
17 | struct ip_callchain; | 15 | struct ip_callchain; |
@@ -48,38 +46,7 @@ struct map { | |||
48 | refcount_t refcnt; | 46 | refcount_t refcnt; |
49 | }; | 47 | }; |
50 | 48 | ||
51 | #define KMAP_NAME_LEN 256 | 49 | struct kmap; |
52 | |||
53 | struct kmap { | ||
54 | struct ref_reloc_sym *ref_reloc_sym; | ||
55 | struct map_groups *kmaps; | ||
56 | char name[KMAP_NAME_LEN]; | ||
57 | }; | ||
58 | |||
59 | struct maps { | ||
60 | struct rb_root entries; | ||
61 | struct rb_root names; | ||
62 | struct rw_semaphore lock; | ||
63 | }; | ||
64 | |||
65 | struct map_groups { | ||
66 | struct maps maps; | ||
67 | struct machine *machine; | ||
68 | refcount_t refcnt; | ||
69 | }; | ||
70 | |||
71 | struct map_groups *map_groups__new(struct machine *machine); | ||
72 | void map_groups__delete(struct map_groups *mg); | ||
73 | bool map_groups__empty(struct map_groups *mg); | ||
74 | |||
75 | static inline struct map_groups *map_groups__get(struct map_groups *mg) | ||
76 | { | ||
77 | if (mg) | ||
78 | refcount_inc(&mg->refcnt); | ||
79 | return mg; | ||
80 | } | ||
81 | |||
82 | void map_groups__put(struct map_groups *mg); | ||
83 | 50 | ||
84 | struct kmap *__map__kmap(struct map *map); | 51 | struct kmap *__map__kmap(struct map *map); |
85 | struct kmap *map__kmap(struct map *map); | 52 | struct kmap *map__kmap(struct map *map); |
@@ -187,61 +154,9 @@ void map__fixup_end(struct map *map); | |||
187 | 154 | ||
188 | void map__reloc_vmlinux(struct map *map); | 155 | void map__reloc_vmlinux(struct map *map); |
189 | 156 | ||
190 | void maps__insert(struct maps *maps, struct map *map); | ||
191 | void maps__remove(struct maps *maps, struct map *map); | ||
192 | struct map *maps__find(struct maps *maps, u64 addr); | ||
193 | struct map *maps__first(struct maps *maps); | ||
194 | struct map *map__next(struct map *map); | ||
195 | struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, | ||
196 | struct map **mapp); | ||
197 | void map_groups__init(struct map_groups *mg, struct machine *machine); | ||
198 | void map_groups__exit(struct map_groups *mg); | ||
199 | int map_groups__clone(struct thread *thread, | ||
200 | struct map_groups *parent); | ||
201 | size_t map_groups__fprintf(struct map_groups *mg, FILE *fp); | ||
202 | |||
203 | int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, | 157 | int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, |
204 | u64 addr); | 158 | u64 addr); |
205 | 159 | ||
206 | static inline void map_groups__insert(struct map_groups *mg, struct map *map) | ||
207 | { | ||
208 | maps__insert(&mg->maps, map); | ||
209 | map->groups = mg; | ||
210 | } | ||
211 | |||
212 | static inline void map_groups__remove(struct map_groups *mg, struct map *map) | ||
213 | { | ||
214 | maps__remove(&mg->maps, map); | ||
215 | } | ||
216 | |||
217 | static inline struct map *map_groups__find(struct map_groups *mg, u64 addr) | ||
218 | { | ||
219 | return maps__find(&mg->maps, addr); | ||
220 | } | ||
221 | |||
222 | struct map *map_groups__first(struct map_groups *mg); | ||
223 | |||
224 | static inline struct map *map_groups__next(struct map *map) | ||
225 | { | ||
226 | return map__next(map); | ||
227 | } | ||
228 | |||
229 | struct symbol *map_groups__find_symbol(struct map_groups *mg, | ||
230 | u64 addr, struct map **mapp); | ||
231 | |||
232 | struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, | ||
233 | const char *name, | ||
234 | struct map **mapp); | ||
235 | |||
236 | struct addr_map_symbol; | ||
237 | |||
238 | int map_groups__find_ams(struct addr_map_symbol *ams); | ||
239 | |||
240 | int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, | ||
241 | FILE *fp); | ||
242 | |||
243 | struct map *map_groups__find_by_name(struct map_groups *mg, const char *name); | ||
244 | |||
245 | bool __map__is_kernel(const struct map *map); | 160 | bool __map__is_kernel(const struct map *map); |
246 | bool __map__is_extra_kernel_map(const struct map *map); | 161 | bool __map__is_extra_kernel_map(const struct map *map); |
247 | 162 | ||
diff --git a/tools/perf/util/map_groups.h b/tools/perf/util/map_groups.h new file mode 100644 index 000000000000..4dcda33e0fdf --- /dev/null +++ b/tools/perf/util/map_groups.h | |||
@@ -0,0 +1,91 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | ||
2 | #ifndef __PERF_MAP_GROUPS_H | ||
3 | #define __PERF_MAP_GROUPS_H | ||
4 | |||
5 | #include <linux/refcount.h> | ||
6 | #include <linux/rbtree.h> | ||
7 | #include <stdio.h> | ||
8 | #include <stdbool.h> | ||
9 | #include <linux/types.h> | ||
10 | #include "rwsem.h" | ||
11 | |||
12 | struct ref_reloc_sym; | ||
13 | struct machine; | ||
14 | struct map; | ||
15 | struct thread; | ||
16 | |||
17 | struct maps { | ||
18 | struct rb_root entries; | ||
19 | struct rb_root names; | ||
20 | struct rw_semaphore lock; | ||
21 | }; | ||
22 | |||
23 | void maps__insert(struct maps *maps, struct map *map); | ||
24 | void maps__remove(struct maps *maps, struct map *map); | ||
25 | struct map *maps__find(struct maps *maps, u64 addr); | ||
26 | struct map *maps__first(struct maps *maps); | ||
27 | struct map *map__next(struct map *map); | ||
28 | struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, struct map **mapp); | ||
29 | |||
30 | struct map_groups { | ||
31 | struct maps maps; | ||
32 | struct machine *machine; | ||
33 | refcount_t refcnt; | ||
34 | }; | ||
35 | |||
36 | #define KMAP_NAME_LEN 256 | ||
37 | |||
38 | struct kmap { | ||
39 | struct ref_reloc_sym *ref_reloc_sym; | ||
40 | struct map_groups *kmaps; | ||
41 | char name[KMAP_NAME_LEN]; | ||
42 | }; | ||
43 | |||
44 | struct map_groups *map_groups__new(struct machine *machine); | ||
45 | void map_groups__delete(struct map_groups *mg); | ||
46 | bool map_groups__empty(struct map_groups *mg); | ||
47 | |||
48 | static inline struct map_groups *map_groups__get(struct map_groups *mg) | ||
49 | { | ||
50 | if (mg) | ||
51 | refcount_inc(&mg->refcnt); | ||
52 | return mg; | ||
53 | } | ||
54 | |||
55 | void map_groups__put(struct map_groups *mg); | ||
56 | void map_groups__init(struct map_groups *mg, struct machine *machine); | ||
57 | void map_groups__exit(struct map_groups *mg); | ||
58 | int map_groups__clone(struct thread *thread, struct map_groups *parent); | ||
59 | size_t map_groups__fprintf(struct map_groups *mg, FILE *fp); | ||
60 | |||
61 | void map_groups__insert(struct map_groups *mg, struct map *map); | ||
62 | |||
63 | static inline void map_groups__remove(struct map_groups *mg, struct map *map) | ||
64 | { | ||
65 | maps__remove(&mg->maps, map); | ||
66 | } | ||
67 | |||
68 | static inline struct map *map_groups__find(struct map_groups *mg, u64 addr) | ||
69 | { | ||
70 | return maps__find(&mg->maps, addr); | ||
71 | } | ||
72 | |||
73 | struct map *map_groups__first(struct map_groups *mg); | ||
74 | |||
75 | static inline struct map *map_groups__next(struct map *map) | ||
76 | { | ||
77 | return map__next(map); | ||
78 | } | ||
79 | |||
80 | struct symbol *map_groups__find_symbol(struct map_groups *mg, u64 addr, struct map **mapp); | ||
81 | struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, const char *name, struct map **mapp); | ||
82 | |||
83 | struct addr_map_symbol; | ||
84 | |||
85 | int map_groups__find_ams(struct addr_map_symbol *ams); | ||
86 | |||
87 | int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, FILE *fp); | ||
88 | |||
89 | struct map *map_groups__find_by_name(struct map_groups *mg, const char *name); | ||
90 | |||
91 | #endif // __PERF_MAP_GROUPS_H | ||
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index b0192160513d..0030f9b9bf7e 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -42,6 +42,7 @@ | |||
42 | #include "cache.h" | 42 | #include "cache.h" |
43 | #include "color.h" | 43 | #include "color.h" |
44 | #include "map.h" | 44 | #include "map.h" |
45 | #include "map_groups.h" | ||
45 | #include "symbol.h" | 46 | #include "symbol.h" |
46 | #include "thread.h" | 47 | #include "thread.h" |
47 | #include <api/fs/fs.h> | 48 | #include <api/fs/fs.h> |
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 848d1a0f8dc0..6b9a2a70da29 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <inttypes.h> | 7 | #include <inttypes.h> |
8 | 8 | ||
9 | #include "map.h" | 9 | #include "map.h" |
10 | #include "map_groups.h" | ||
10 | #include "symbol.h" | 11 | #include "symbol.h" |
11 | #include "demangle-java.h" | 12 | #include "demangle-java.h" |
12 | #include "demangle-rust.h" | 13 | #include "demangle-rust.h" |