hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/tools/perf/util/map.h
....@@ -6,19 +6,14 @@
66 #include <linux/compiler.h>
77 #include <linux/list.h>
88 #include <linux/rbtree.h>
9
-#include <pthread.h>
109 #include <stdio.h>
1110 #include <string.h>
1211 #include <stdbool.h>
1312 #include <linux/types.h>
14
-#include "rwsem.h"
1513
1614 struct dso;
17
-struct ip_callchain;
18
-struct ref_reloc_sym;
19
-struct map_groups;
15
+struct maps;
2016 struct machine;
21
-struct perf_evsel;
2217
2318 struct map {
2419 union {
....@@ -27,15 +22,11 @@
2722 };
2823 u64 start;
2924 u64 end;
30
- bool erange_warned;
31
- u32 priv;
25
+ bool erange_warned:1;
26
+ bool priv:1;
3227 u32 prot;
33
- u32 flags;
3428 u64 pgoff;
3529 u64 reloc;
36
- u32 maj, min; /* only valid for MMAP2 record */
37
- u64 ino; /* only valid for MMAP2 record */
38
- u64 ino_generation;/* only valid for MMAP2 record */
3930
4031 /* ip -> dso rip */
4132 u64 (*map_ip)(struct map *, u64);
....@@ -43,45 +34,15 @@
4334 u64 (*unmap_ip)(struct map *, u64);
4435
4536 struct dso *dso;
46
- struct map_groups *groups;
4737 refcount_t refcnt;
38
+ u32 flags;
4839 };
4940
50
-#define KMAP_NAME_LEN 256
51
-
52
-struct kmap {
53
- struct ref_reloc_sym *ref_reloc_sym;
54
- struct map_groups *kmaps;
55
- char name[KMAP_NAME_LEN];
56
-};
57
-
58
-struct maps {
59
- struct rb_root entries;
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);
41
+struct kmap;
8142
8243 struct kmap *__map__kmap(struct map *map);
8344 struct kmap *map__kmap(struct map *map);
84
-struct map_groups *map__kmaps(struct map *map);
45
+struct maps *map__kmaps(struct map *map);
8546
8647 static inline u64 map__map_ip(struct map *map, u64 ip)
8748 {
....@@ -141,9 +102,11 @@
141102
142103 void map__init(struct map *map,
143104 u64 start, u64 end, u64 pgoff, struct dso *dso);
105
+
106
+struct dso_id;
107
+
144108 struct map *map__new(struct machine *machine, u64 start, u64 len,
145
- u64 pgoff, u32 d_maj, u32 d_min, u64 ino,
146
- u64 ino_gen, u32 prot, u32 flags,
109
+ u64 pgoff, struct dso_id *id, u32 prot, u32 flags,
147110 char *filename, struct thread *thread);
148111 struct map *map__new2(u64 start, struct dso *dso);
149112 void map__delete(struct map *map);
....@@ -178,69 +141,20 @@
178141 void map__fixup_start(struct map *map);
179142 void map__fixup_end(struct map *map);
180143
181
-void map__reloc_vmlinux(struct map *map);
182
-
183
-void maps__insert(struct maps *maps, struct map *map);
184
-void maps__remove(struct maps *maps, struct map *map);
185
-struct map *maps__find(struct maps *maps, u64 addr);
186
-struct map *maps__first(struct maps *maps);
187
-struct map *map__next(struct map *map);
188
-struct symbol *maps__find_symbol_by_name(struct maps *maps, const char *name,
189
- struct map **mapp);
190
-void map_groups__init(struct map_groups *mg, struct machine *machine);
191
-void map_groups__exit(struct map_groups *mg);
192
-int map_groups__clone(struct thread *thread,
193
- struct map_groups *parent);
194
-size_t map_groups__fprintf(struct map_groups *mg, FILE *fp);
195
-
196144 int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name,
197145 u64 addr);
198146
199
-static inline void map_groups__insert(struct map_groups *mg, struct map *map)
200
-{
201
- maps__insert(&mg->maps, map);
202
- map->groups = mg;
203
-}
204
-
205
-static inline void map_groups__remove(struct map_groups *mg, struct map *map)
206
-{
207
- maps__remove(&mg->maps, map);
208
-}
209
-
210
-static inline struct map *map_groups__find(struct map_groups *mg, u64 addr)
211
-{
212
- return maps__find(&mg->maps, addr);
213
-}
214
-
215
-struct map *map_groups__first(struct map_groups *mg);
216
-
217
-static inline struct map *map_groups__next(struct map *map)
218
-{
219
- return map__next(map);
220
-}
221
-
222
-struct symbol *map_groups__find_symbol(struct map_groups *mg,
223
- u64 addr, struct map **mapp);
224
-
225
-struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
226
- const char *name,
227
- struct map **mapp);
228
-
229
-struct addr_map_symbol;
230
-
231
-int map_groups__find_ams(struct addr_map_symbol *ams);
232
-
233
-int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
234
- FILE *fp);
235
-
236
-struct map *map_groups__find_by_name(struct map_groups *mg, const char *name);
237
-
238147 bool __map__is_kernel(const struct map *map);
239148 bool __map__is_extra_kernel_map(const struct map *map);
149
+bool __map__is_bpf_prog(const struct map *map);
150
+bool __map__is_bpf_image(const struct map *map);
151
+bool __map__is_ool(const struct map *map);
240152
241153 static inline bool __map__is_kmodule(const struct map *map)
242154 {
243
- return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map);
155
+ return !__map__is_kernel(map) && !__map__is_extra_kernel_map(map) &&
156
+ !__map__is_bpf_prog(map) && !__map__is_ool(map) &&
157
+ !__map__is_bpf_image(map);
244158 }
245159
246160 bool map__has_symbols(const struct map *map);
....@@ -252,4 +166,23 @@
252166 return !strcmp(name, ENTRY_TRAMPOLINE_NAME);
253167 }
254168
169
+static inline bool is_bpf_image(const char *name)
170
+{
171
+ return strncmp(name, "bpf_trampoline_", sizeof("bpf_trampoline_") - 1) == 0 ||
172
+ strncmp(name, "bpf_dispatcher_", sizeof("bpf_dispatcher_") - 1) == 0;
173
+}
174
+
175
+static inline int is_anon_memory(const char *filename)
176
+{
177
+ return !strcmp(filename, "//anon") ||
178
+ !strncmp(filename, "/dev/zero", sizeof("/dev/zero") - 1) ||
179
+ !strncmp(filename, "/anon_hugepage", sizeof("/anon_hugepage") - 1);
180
+}
181
+
182
+static inline int is_no_dso_memory(const char *filename)
183
+{
184
+ return !strncmp(filename, "[stack", 6) ||
185
+ !strncmp(filename, "/SYSV", 5) ||
186
+ !strcmp(filename, "[heap]");
187
+}
255188 #endif /* __PERF_MAP_H */