diff options
| -rw-r--r-- | tools/perf/builtin-kmem.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/map.h | 25 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 77 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 7 |
4 files changed, 86 insertions, 25 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 15635612e596..ee05dba9609a 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
| @@ -377,7 +377,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session, | |||
| 377 | if (is_caller) { | 377 | if (is_caller) { |
| 378 | addr = data->call_site; | 378 | addr = data->call_site; |
| 379 | if (!raw_ip) | 379 | if (!raw_ip) |
| 380 | sym = machine__find_function(machine, addr, &map, NULL); | 380 | sym = machine__find_kernel_function(machine, addr, &map, NULL); |
| 381 | } else | 381 | } else |
| 382 | addr = data->ptr; | 382 | addr = data->ptr; |
| 383 | 383 | ||
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 881dba4f8203..f39134512829 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
| @@ -30,6 +30,7 @@ struct map { | |||
| 30 | u64 start; | 30 | u64 start; |
| 31 | u64 end; | 31 | u64 end; |
| 32 | enum map_type type; | 32 | enum map_type type; |
| 33 | u32 priv; | ||
| 33 | u64 pgoff; | 34 | u64 pgoff; |
| 34 | 35 | ||
| 35 | /* ip -> dso rip */ | 36 | /* ip -> dso rip */ |
| @@ -66,6 +67,12 @@ struct machine { | |||
| 66 | struct map *vmlinux_maps[MAP__NR_TYPES]; | 67 | struct map *vmlinux_maps[MAP__NR_TYPES]; |
| 67 | }; | 68 | }; |
| 68 | 69 | ||
| 70 | static inline | ||
| 71 | struct map *machine__kernel_map(struct machine *self, enum map_type type) | ||
| 72 | { | ||
| 73 | return self->vmlinux_maps[type]; | ||
| 74 | } | ||
| 75 | |||
| 69 | static inline struct kmap *map__kmap(struct map *self) | 76 | static inline struct kmap *map__kmap(struct map *self) |
| 70 | { | 77 | { |
| 71 | return (struct kmap *)(self + 1); | 78 | return (struct kmap *)(self + 1); |
| @@ -173,11 +180,21 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *self, | |||
| 173 | struct map **mapp, | 180 | struct map **mapp, |
| 174 | symbol_filter_t filter); | 181 | symbol_filter_t filter); |
| 175 | 182 | ||
| 176 | static inline struct symbol *machine__find_function(struct machine *self, | 183 | static inline |
| 177 | u64 addr, struct map **mapp, | 184 | struct symbol *machine__find_kernel_symbol(struct machine *self, |
| 178 | symbol_filter_t filter) | 185 | enum map_type type, u64 addr, |
| 186 | struct map **mapp, | ||
| 187 | symbol_filter_t filter) | ||
| 188 | { | ||
| 189 | return map_groups__find_symbol(&self->kmaps, type, addr, mapp, filter); | ||
| 190 | } | ||
| 191 | |||
| 192 | static inline | ||
| 193 | struct symbol *machine__find_kernel_function(struct machine *self, u64 addr, | ||
| 194 | struct map **mapp, | ||
| 195 | symbol_filter_t filter) | ||
| 179 | { | 196 | { |
| 180 | return map_groups__find_symbol(&self->kmaps, MAP__FUNCTION, addr, mapp, filter); | 197 | return machine__find_kernel_symbol(self, MAP__FUNCTION, addr, mapp, filter); |
| 181 | } | 198 | } |
| 182 | 199 | ||
| 183 | static inline | 200 | static inline |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index caa890f8e2c0..4c0146a49063 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
| @@ -1983,23 +1983,23 @@ void dso__read_running_kernel_build_id(struct dso *self, struct machine *machine | |||
| 1983 | self->has_build_id = true; | 1983 | self->has_build_id = true; |
| 1984 | } | 1984 | } |
| 1985 | 1985 | ||
| 1986 | static struct dso *dsos__create_kernel(struct machine *machine) | 1986 | static struct dso *machine__create_kernel(struct machine *self) |
| 1987 | { | 1987 | { |
| 1988 | const char *vmlinux_name = NULL; | 1988 | const char *vmlinux_name = NULL; |
| 1989 | struct dso *kernel; | 1989 | struct dso *kernel; |
| 1990 | 1990 | ||
| 1991 | if (machine__is_host(machine)) { | 1991 | if (machine__is_host(self)) { |
| 1992 | vmlinux_name = symbol_conf.vmlinux_name; | 1992 | vmlinux_name = symbol_conf.vmlinux_name; |
| 1993 | kernel = dso__new_kernel(vmlinux_name); | 1993 | kernel = dso__new_kernel(vmlinux_name); |
| 1994 | } else { | 1994 | } else { |
| 1995 | if (machine__is_default_guest(machine)) | 1995 | if (machine__is_default_guest(self)) |
| 1996 | vmlinux_name = symbol_conf.default_guest_vmlinux_name; | 1996 | vmlinux_name = symbol_conf.default_guest_vmlinux_name; |
| 1997 | kernel = dso__new_guest_kernel(machine, vmlinux_name); | 1997 | kernel = dso__new_guest_kernel(self, vmlinux_name); |
| 1998 | } | 1998 | } |
| 1999 | 1999 | ||
| 2000 | if (kernel != NULL) { | 2000 | if (kernel != NULL) { |
| 2001 | dso__read_running_kernel_build_id(kernel, machine); | 2001 | dso__read_running_kernel_build_id(kernel, self); |
| 2002 | dsos__add(&machine->kernel_dsos, kernel); | 2002 | dsos__add(&self->kernel_dsos, kernel); |
| 2003 | } | 2003 | } |
| 2004 | return kernel; | 2004 | return kernel; |
| 2005 | } | 2005 | } |
| @@ -2026,6 +2026,23 @@ int __machine__create_kernel_maps(struct machine *self, struct dso *kernel) | |||
| 2026 | return 0; | 2026 | return 0; |
| 2027 | } | 2027 | } |
| 2028 | 2028 | ||
| 2029 | int machine__create_kernel_maps(struct machine *self) | ||
| 2030 | { | ||
| 2031 | struct dso *kernel = machine__create_kernel(self); | ||
| 2032 | |||
| 2033 | if (kernel == NULL || | ||
| 2034 | __machine__create_kernel_maps(self, kernel) < 0) | ||
| 2035 | return -1; | ||
| 2036 | |||
| 2037 | if (symbol_conf.use_modules && machine__create_modules(self) < 0) | ||
| 2038 | pr_debug("Problems creating module maps, continuing anyway...\n"); | ||
| 2039 | /* | ||
| 2040 | * Now that we have all the maps created, just set the ->end of them: | ||
| 2041 | */ | ||
| 2042 | map_groups__fixup_end(&self->kmaps); | ||
| 2043 | return 0; | ||
| 2044 | } | ||
| 2045 | |||
| 2029 | static void vmlinux_path__exit(void) | 2046 | static void vmlinux_path__exit(void) |
| 2030 | { | 2047 | { |
| 2031 | while (--vmlinux_path__nr_entries >= 0) { | 2048 | while (--vmlinux_path__nr_entries >= 0) { |
| @@ -2144,25 +2161,12 @@ out_free_comm_list: | |||
| 2144 | 2161 | ||
| 2145 | int machines__create_kernel_maps(struct rb_root *self, pid_t pid) | 2162 | int machines__create_kernel_maps(struct rb_root *self, pid_t pid) |
| 2146 | { | 2163 | { |
| 2147 | struct dso *kernel; | ||
| 2148 | struct machine *machine = machines__findnew(self, pid); | 2164 | struct machine *machine = machines__findnew(self, pid); |
| 2149 | 2165 | ||
| 2150 | if (machine == NULL) | 2166 | if (machine == NULL) |
| 2151 | return -1; | 2167 | return -1; |
| 2152 | kernel = dsos__create_kernel(machine); | ||
| 2153 | if (kernel == NULL) | ||
| 2154 | return -1; | ||
| 2155 | |||
| 2156 | if (__machine__create_kernel_maps(machine, kernel) < 0) | ||
| 2157 | return -1; | ||
| 2158 | 2168 | ||
| 2159 | if (symbol_conf.use_modules && machine__create_modules(machine) < 0) | 2169 | return machine__create_kernel_maps(machine); |
| 2160 | pr_debug("Problems creating module maps, continuing anyway...\n"); | ||
| 2161 | /* | ||
| 2162 | * Now that we have all the maps created, just set the ->end of them: | ||
| 2163 | */ | ||
| 2164 | map_groups__fixup_end(&machine->kmaps); | ||
| 2165 | return 0; | ||
| 2166 | } | 2170 | } |
| 2167 | 2171 | ||
| 2168 | static int hex(char ch) | 2172 | static int hex(char ch) |
| @@ -2248,3 +2252,36 @@ failure: | |||
| 2248 | 2252 | ||
| 2249 | return ret; | 2253 | return ret; |
| 2250 | } | 2254 | } |
| 2255 | |||
| 2256 | int machine__load_kallsyms(struct machine *self, const char *filename, | ||
| 2257 | enum map_type type, symbol_filter_t filter) | ||
| 2258 | { | ||
| 2259 | struct map *map = self->vmlinux_maps[type]; | ||
| 2260 | int ret = dso__load_kallsyms(map->dso, filename, map, filter); | ||
| 2261 | |||
| 2262 | if (ret > 0) { | ||
| 2263 | dso__set_loaded(map->dso, type); | ||
| 2264 | /* | ||
| 2265 | * Since /proc/kallsyms will have multiple sessions for the | ||
| 2266 | * kernel, with modules between them, fixup the end of all | ||
| 2267 | * sections. | ||
| 2268 | */ | ||
| 2269 | __map_groups__fixup_end(&self->kmaps, type); | ||
| 2270 | } | ||
| 2271 | |||
| 2272 | return ret; | ||
| 2273 | } | ||
| 2274 | |||
| 2275 | int machine__load_vmlinux_path(struct machine *self, enum map_type type, | ||
| 2276 | symbol_filter_t filter) | ||
| 2277 | { | ||
| 2278 | struct map *map = self->vmlinux_maps[type]; | ||
| 2279 | int ret = dso__load_vmlinux_path(map->dso, map, filter); | ||
| 2280 | |||
| 2281 | if (ret > 0) { | ||
| 2282 | dso__set_loaded(map->dso, type); | ||
| 2283 | map__reloc_vmlinux(map); | ||
| 2284 | } | ||
| 2285 | |||
| 2286 | return ret; | ||
| 2287 | } | ||
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 2cec6a10716a..a517c17407b7 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
| @@ -162,6 +162,11 @@ int dso__load_vmlinux_path(struct dso *self, struct map *map, | |||
| 162 | symbol_filter_t filter); | 162 | symbol_filter_t filter); |
| 163 | int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map, | 163 | int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map, |
| 164 | symbol_filter_t filter); | 164 | symbol_filter_t filter); |
| 165 | int machine__load_kallsyms(struct machine *self, const char *filename, | ||
| 166 | enum map_type type, symbol_filter_t filter); | ||
| 167 | int machine__load_vmlinux_path(struct machine *self, enum map_type type, | ||
| 168 | symbol_filter_t filter); | ||
| 169 | |||
| 165 | size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp); | 170 | size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp); |
| 166 | size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits); | 171 | size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits); |
| 167 | 172 | ||
| @@ -199,6 +204,8 @@ int kallsyms__parse(const char *filename, void *arg, | |||
| 199 | char type, u64 start)); | 204 | char type, u64 start)); |
| 200 | 205 | ||
| 201 | int __machine__create_kernel_maps(struct machine *self, struct dso *kernel); | 206 | int __machine__create_kernel_maps(struct machine *self, struct dso *kernel); |
| 207 | int machine__create_kernel_maps(struct machine *self); | ||
| 208 | |||
| 202 | int machines__create_kernel_maps(struct rb_root *self, pid_t pid); | 209 | int machines__create_kernel_maps(struct rb_root *self, pid_t pid); |
| 203 | int machines__create_guest_kernel_maps(struct rb_root *self); | 210 | int machines__create_guest_kernel_maps(struct rb_root *self); |
| 204 | 211 | ||
