diff options
| -rw-r--r-- | tools/perf/util/header.c | 11 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 57 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 1 |
3 files changed, 42 insertions, 27 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index d4f3101773db..b6c1ad123ca9 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
| @@ -726,7 +726,16 @@ static int perf_header__read_build_ids_abi_quirk(struct perf_header *header, | |||
| 726 | return -1; | 726 | return -1; |
| 727 | 727 | ||
| 728 | bev.header = old_bev.header; | 728 | bev.header = old_bev.header; |
| 729 | bev.pid = 0; | 729 | |
| 730 | /* | ||
| 731 | * As the pid is the missing value, we need to fill | ||
| 732 | * it properly. The header.misc value give us nice hint. | ||
| 733 | */ | ||
| 734 | bev.pid = HOST_KERNEL_ID; | ||
| 735 | if (bev.header.misc == PERF_RECORD_MISC_GUEST_USER || | ||
| 736 | bev.header.misc == PERF_RECORD_MISC_GUEST_KERNEL) | ||
| 737 | bev.pid = DEFAULT_GUEST_KERNEL_ID; | ||
| 738 | |||
| 730 | memcpy(bev.build_id, old_bev.build_id, sizeof(bev.build_id)); | 739 | memcpy(bev.build_id, old_bev.build_id, sizeof(bev.build_id)); |
| 731 | __event_process_build_id(&bev, filename, session); | 740 | __event_process_build_id(&bev, filename, session); |
| 732 | 741 | ||
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index a8b53714542a..e142c21ae9a5 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
| @@ -2181,27 +2181,22 @@ size_t machines__fprintf_dsos_buildid(struct rb_root *machines, | |||
| 2181 | return ret; | 2181 | return ret; |
| 2182 | } | 2182 | } |
| 2183 | 2183 | ||
| 2184 | struct dso *dso__new_kernel(const char *name) | 2184 | static struct dso* |
| 2185 | dso__kernel_findnew(struct machine *machine, const char *name, | ||
| 2186 | const char *short_name, int dso_type) | ||
| 2185 | { | 2187 | { |
| 2186 | struct dso *dso = dso__new(name ?: "[kernel.kallsyms]"); | 2188 | /* |
| 2187 | 2189 | * The kernel dso could be created by build_id processing. | |
| 2188 | if (dso != NULL) { | 2190 | */ |
| 2189 | dso__set_short_name(dso, "[kernel]"); | 2191 | struct dso *dso = __dsos__findnew(&machine->kernel_dsos, name); |
| 2190 | dso->kernel = DSO_TYPE_KERNEL; | ||
| 2191 | } | ||
| 2192 | |||
| 2193 | return dso; | ||
| 2194 | } | ||
| 2195 | 2192 | ||
| 2196 | static struct dso *dso__new_guest_kernel(struct machine *machine, | 2193 | /* |
| 2197 | const char *name) | 2194 | * We need to run this in all cases, since during the build_id |
| 2198 | { | 2195 | * processing we had no idea this was the kernel dso. |
| 2199 | char bf[PATH_MAX]; | 2196 | */ |
| 2200 | struct dso *dso = dso__new(name ?: machine__mmap_name(machine, bf, | ||
| 2201 | sizeof(bf))); | ||
| 2202 | if (dso != NULL) { | 2197 | if (dso != NULL) { |
| 2203 | dso__set_short_name(dso, "[guest.kernel]"); | 2198 | dso__set_short_name(dso, short_name); |
| 2204 | dso->kernel = DSO_TYPE_GUEST_KERNEL; | 2199 | dso->kernel = dso_type; |
| 2205 | } | 2200 | } |
| 2206 | 2201 | ||
| 2207 | return dso; | 2202 | return dso; |
| @@ -2219,24 +2214,36 @@ void dso__read_running_kernel_build_id(struct dso *dso, struct machine *machine) | |||
| 2219 | dso->has_build_id = true; | 2214 | dso->has_build_id = true; |
| 2220 | } | 2215 | } |
| 2221 | 2216 | ||
| 2222 | static struct dso *machine__create_kernel(struct machine *machine) | 2217 | static struct dso *machine__get_kernel(struct machine *machine) |
| 2223 | { | 2218 | { |
| 2224 | const char *vmlinux_name = NULL; | 2219 | const char *vmlinux_name = NULL; |
| 2225 | struct dso *kernel; | 2220 | struct dso *kernel; |
| 2226 | 2221 | ||
| 2227 | if (machine__is_host(machine)) { | 2222 | if (machine__is_host(machine)) { |
| 2228 | vmlinux_name = symbol_conf.vmlinux_name; | 2223 | vmlinux_name = symbol_conf.vmlinux_name; |
| 2229 | kernel = dso__new_kernel(vmlinux_name); | 2224 | if (!vmlinux_name) |
| 2225 | vmlinux_name = "[kernel.kallsyms]"; | ||
| 2226 | |||
| 2227 | kernel = dso__kernel_findnew(machine, vmlinux_name, | ||
| 2228 | "[kernel]", | ||
| 2229 | DSO_TYPE_KERNEL); | ||
| 2230 | } else { | 2230 | } else { |
| 2231 | char bf[PATH_MAX]; | ||
| 2232 | |||
| 2231 | if (machine__is_default_guest(machine)) | 2233 | if (machine__is_default_guest(machine)) |
| 2232 | vmlinux_name = symbol_conf.default_guest_vmlinux_name; | 2234 | vmlinux_name = symbol_conf.default_guest_vmlinux_name; |
| 2233 | kernel = dso__new_guest_kernel(machine, vmlinux_name); | 2235 | if (!vmlinux_name) |
| 2236 | vmlinux_name = machine__mmap_name(machine, bf, | ||
| 2237 | sizeof(bf)); | ||
| 2238 | |||
| 2239 | kernel = dso__kernel_findnew(machine, vmlinux_name, | ||
| 2240 | "[guest.kernel]", | ||
| 2241 | DSO_TYPE_GUEST_KERNEL); | ||
| 2234 | } | 2242 | } |
| 2235 | 2243 | ||
| 2236 | if (kernel != NULL) { | 2244 | if (kernel != NULL && (!kernel->has_build_id)) |
| 2237 | dso__read_running_kernel_build_id(kernel, machine); | 2245 | dso__read_running_kernel_build_id(kernel, machine); |
| 2238 | dsos__add(&machine->kernel_dsos, kernel); | 2246 | |
| 2239 | } | ||
| 2240 | return kernel; | 2247 | return kernel; |
| 2241 | } | 2248 | } |
| 2242 | 2249 | ||
| @@ -2340,7 +2347,7 @@ void machine__destroy_kernel_maps(struct machine *machine) | |||
| 2340 | 2347 | ||
| 2341 | int machine__create_kernel_maps(struct machine *machine) | 2348 | int machine__create_kernel_maps(struct machine *machine) |
| 2342 | { | 2349 | { |
| 2343 | struct dso *kernel = machine__create_kernel(machine); | 2350 | struct dso *kernel = machine__get_kernel(machine); |
| 2344 | 2351 | ||
| 2345 | if (kernel == NULL || | 2352 | if (kernel == NULL || |
| 2346 | __machine__create_kernel_maps(machine, kernel) < 0) | 2353 | __machine__create_kernel_maps(machine, kernel) < 0) |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 325ee36a9d29..4f377d92e75a 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
| @@ -155,7 +155,6 @@ struct dso { | |||
| 155 | }; | 155 | }; |
| 156 | 156 | ||
| 157 | struct dso *dso__new(const char *name); | 157 | struct dso *dso__new(const char *name); |
| 158 | struct dso *dso__new_kernel(const char *name); | ||
| 159 | void dso__delete(struct dso *dso); | 158 | void dso__delete(struct dso *dso); |
| 160 | 159 | ||
| 161 | int dso__name_len(const struct dso *dso); | 160 | int dso__name_len(const struct dso *dso); |
