Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+106 -87
+1
tools/perf/arch/arm/tests/dwarf-unwind.c
··· 3 3 #include "perf_regs.h" 4 4 #include "thread.h" 5 5 #include "map.h" 6 + #include "map_groups.h" 6 7 #include "event.h" 7 8 #include "debug.h" 8 9 #include "tests/tests.h"
+1
tools/perf/arch/arm64/tests/dwarf-unwind.c
··· 3 3 #include "perf_regs.h" 4 4 #include "thread.h" 5 5 #include "map.h" 6 + #include "map_groups.h" 6 7 #include "event.h" 7 8 #include "debug.h" 8 9 #include "tests/tests.h"
+1
tools/perf/arch/powerpc/tests/dwarf-unwind.c
··· 3 3 #include "perf_regs.h" 4 4 #include "thread.h" 5 5 #include "map.h" 6 + #include "map_groups.h" 6 7 #include "event.h" 7 8 #include "debug.h" 8 9 #include "tests/tests.h"
+1
tools/perf/arch/x86/tests/dwarf-unwind.c
··· 3 3 #include "perf_regs.h" 4 4 #include "thread.h" 5 5 #include "map.h" 6 + #include "map_groups.h" 6 7 #include "event.h" 7 8 #include "debug.h" 8 9 #include "tests/tests.h"
+1
tools/perf/ui/stdio/hist.c
··· 5 5 #include "../../util/util.h" 6 6 #include "../../util/hist.h" 7 7 #include "../../util/map.h" 8 + #include "../../util/map_groups.h" 8 9 #include "../../util/sort.h" 9 10 #include "../../util/evsel.h" 10 11 #include "../../util/srcline.h"
+1 -1
tools/perf/util/machine.h
··· 4 4 5 5 #include <sys/types.h> 6 6 #include <linux/rbtree.h> 7 - #include "map.h" 7 + #include "map_groups.h" 8 8 #include "dso.h" 9 9 #include "event.h" 10 10 #include "rwsem.h"
+6
tools/perf/util/map.c
··· 557 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 566 static void __maps__purge(struct maps *maps) 561 567 { 562 568 struct rb_root *root = &maps->entries;
+1 -86
tools/perf/util/map.h
··· 6 6 #include <linux/compiler.h> 7 7 #include <linux/list.h> 8 8 #include <linux/rbtree.h> 9 - #include <pthread.h> 10 9 #include <stdio.h> 11 10 #include <string.h> 12 11 #include <stdbool.h> 13 12 #include <linux/types.h> 14 - #include "rwsem.h" 15 13 16 14 struct dso; 17 15 struct ip_callchain; ··· 46 48 refcount_t refcnt; 47 49 }; 48 50 49 - #define KMAP_NAME_LEN 256 50 - 51 - struct kmap { 52 - struct ref_reloc_sym *ref_reloc_sym; 53 - struct map_groups *kmaps; 54 - char name[KMAP_NAME_LEN]; 55 - }; 56 - 57 - struct maps { 58 - struct rb_root entries; 59 - struct rb_root names; 60 - struct rw_semaphore lock; 61 - }; 62 - 63 - struct map_groups { 64 - struct maps maps; 65 - struct machine *machine; 66 - refcount_t refcnt; 67 - }; 68 - 69 - struct map_groups *map_groups__new(struct machine *machine); 70 - void map_groups__delete(struct map_groups *mg); 71 - bool map_groups__empty(struct map_groups *mg); 72 - 73 - static inline struct map_groups *map_groups__get(struct map_groups *mg) 74 - { 75 - if (mg) 76 - refcount_inc(&mg->refcnt); 77 - return mg; 78 - } 79 - 80 - void map_groups__put(struct map_groups *mg); 51 + struct kmap; 81 52 82 53 struct kmap *__map__kmap(struct map *map); 83 54 struct kmap *map__kmap(struct map *map); ··· 154 187 155 188 void map__reloc_vmlinux(struct map *map); 156 189 157 - void maps__insert(struct maps *maps, struct map *map); 158 - void maps__remove(struct maps *maps, struct map *map); 159 - struct map *maps__find(struct maps *maps, u64 addr); 160 - struct map *maps__first(struct maps *maps); 161 - struct map *map__next(struct map *map); 162 - struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name, 163 - struct map **mapp); 164 - void map_groups__init(struct map_groups *mg, struct machine *machine); 165 - void map_groups__exit(struct map_groups *mg); 166 - int map_groups__clone(struct thread *thread, 167 - struct map_groups *parent); 168 - size_t map_groups__fprintf(struct map_groups *mg, FILE *fp); 169 - 170 190 int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, 171 191 u64 addr); 172 - 173 - static inline void map_groups__insert(struct map_groups *mg, struct map *map) 174 - { 175 - maps__insert(&mg->maps, map); 176 - map->groups = mg; 177 - } 178 - 179 - static inline void map_groups__remove(struct map_groups *mg, struct map *map) 180 - { 181 - maps__remove(&mg->maps, map); 182 - } 183 - 184 - static inline struct map *map_groups__find(struct map_groups *mg, u64 addr) 185 - { 186 - return maps__find(&mg->maps, addr); 187 - } 188 - 189 - struct map *map_groups__first(struct map_groups *mg); 190 - 191 - static inline struct map *map_groups__next(struct map *map) 192 - { 193 - return map__next(map); 194 - } 195 - 196 - struct symbol *map_groups__find_symbol(struct map_groups *mg, 197 - u64 addr, struct map **mapp); 198 - 199 - struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg, 200 - const char *name, 201 - struct map **mapp); 202 - 203 - struct addr_map_symbol; 204 - 205 - int map_groups__find_ams(struct addr_map_symbol *ams); 206 - 207 - int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map, 208 - FILE *fp); 209 - 210 - struct map *map_groups__find_by_name(struct map_groups *mg, const char *name); 211 192 212 193 bool __map__is_kernel(const struct map *map); 213 194 bool __map__is_extra_kernel_map(const struct map *map);
+91
tools/perf/util/map_groups.h
··· 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
+1
tools/perf/util/probe-event.c
··· 42 42 #include "cache.h" 43 43 #include "color.h" 44 44 #include "map.h" 45 + #include "map_groups.h" 45 46 #include "symbol.h" 46 47 #include "thread.h" 47 48 #include <api/fs/fs.h>
+1
tools/perf/util/symbol-elf.c
··· 7 7 #include <inttypes.h> 8 8 9 9 #include "map.h" 10 + #include "map_groups.h" 10 11 #include "symbol.h" 11 12 #include "demangle-java.h" 12 13 #include "demangle-rust.h"