| .. | .. |
|---|
| 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 | | -struct ip_callchain; |
|---|
| 18 | | -struct ref_reloc_sym; |
|---|
| 19 | | -struct map_groups; |
|---|
| 15 | +struct maps; |
|---|
| 20 | 16 | struct machine; |
|---|
| 21 | | -struct perf_evsel; |
|---|
| 22 | 17 | |
|---|
| 23 | 18 | struct map { |
|---|
| 24 | 19 | union { |
|---|
| .. | .. |
|---|
| 27 | 22 | }; |
|---|
| 28 | 23 | u64 start; |
|---|
| 29 | 24 | u64 end; |
|---|
| 30 | | - bool erange_warned; |
|---|
| 31 | | - u32 priv; |
|---|
| 25 | + bool erange_warned:1; |
|---|
| 26 | + bool priv:1; |
|---|
| 32 | 27 | u32 prot; |
|---|
| 33 | | - u32 flags; |
|---|
| 34 | 28 | u64 pgoff; |
|---|
| 35 | 29 | 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 */ |
|---|
| 39 | 30 | |
|---|
| 40 | 31 | /* ip -> dso rip */ |
|---|
| 41 | 32 | u64 (*map_ip)(struct map *, u64); |
|---|
| .. | .. |
|---|
| 43 | 34 | u64 (*unmap_ip)(struct map *, u64); |
|---|
| 44 | 35 | |
|---|
| 45 | 36 | struct dso *dso; |
|---|
| 46 | | - struct map_groups *groups; |
|---|
| 47 | 37 | refcount_t refcnt; |
|---|
| 38 | + u32 flags; |
|---|
| 48 | 39 | }; |
|---|
| 49 | 40 | |
|---|
| 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; |
|---|
| 81 | 42 | |
|---|
| 82 | 43 | struct kmap *__map__kmap(struct map *map); |
|---|
| 83 | 44 | struct kmap *map__kmap(struct map *map); |
|---|
| 84 | | -struct map_groups *map__kmaps(struct map *map); |
|---|
| 45 | +struct maps *map__kmaps(struct map *map); |
|---|
| 85 | 46 | |
|---|
| 86 | 47 | static inline u64 map__map_ip(struct map *map, u64 ip) |
|---|
| 87 | 48 | { |
|---|
| .. | .. |
|---|
| 141 | 102 | |
|---|
| 142 | 103 | void map__init(struct map *map, |
|---|
| 143 | 104 | u64 start, u64 end, u64 pgoff, struct dso *dso); |
|---|
| 105 | + |
|---|
| 106 | +struct dso_id; |
|---|
| 107 | + |
|---|
| 144 | 108 | 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, |
|---|
| 147 | 110 | char *filename, struct thread *thread); |
|---|
| 148 | 111 | struct map *map__new2(u64 start, struct dso *dso); |
|---|
| 149 | 112 | void map__delete(struct map *map); |
|---|
| .. | .. |
|---|
| 178 | 141 | void map__fixup_start(struct map *map); |
|---|
| 179 | 142 | void map__fixup_end(struct map *map); |
|---|
| 180 | 143 | |
|---|
| 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 | | - |
|---|
| 196 | 144 | int map__set_kallsyms_ref_reloc_sym(struct map *map, const char *symbol_name, |
|---|
| 197 | 145 | u64 addr); |
|---|
| 198 | 146 | |
|---|
| 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 | | - |
|---|
| 238 | 147 | bool __map__is_kernel(const struct map *map); |
|---|
| 239 | 148 | 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); |
|---|
| 240 | 152 | |
|---|
| 241 | 153 | static inline bool __map__is_kmodule(const struct map *map) |
|---|
| 242 | 154 | { |
|---|
| 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); |
|---|
| 244 | 158 | } |
|---|
| 245 | 159 | |
|---|
| 246 | 160 | bool map__has_symbols(const struct map *map); |
|---|
| .. | .. |
|---|
| 252 | 166 | return !strcmp(name, ENTRY_TRAMPOLINE_NAME); |
|---|
| 253 | 167 | } |
|---|
| 254 | 168 | |
|---|
| 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 | +} |
|---|
| 255 | 188 | #endif /* __PERF_MAP_H */ |
|---|