diff options
| -rw-r--r-- | tools/perf/builtin-kmem.c | 4 | ||||
| -rw-r--r-- | tools/perf/util/event.c | 9 | ||||
| -rw-r--r-- | tools/perf/util/map.c | 24 | ||||
| -rw-r--r-- | tools/perf/util/map.h | 12 | ||||
| -rw-r--r-- | tools/perf/util/probe-event.c | 20 | ||||
| -rw-r--r-- | tools/perf/util/session.c | 7 | ||||
| -rw-r--r-- | tools/perf/util/symbol.c | 71 | ||||
| -rw-r--r-- | tools/perf/util/symbol.h | 8 |
8 files changed, 74 insertions, 81 deletions
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c index 20674759464e..15635612e596 100644 --- a/tools/perf/builtin-kmem.c +++ b/tools/perf/builtin-kmem.c | |||
| @@ -370,7 +370,6 @@ static void __print_result(struct rb_root *root, struct perf_session *session, | |||
| 370 | struct alloc_stat *data = rb_entry(next, struct alloc_stat, | 370 | struct alloc_stat *data = rb_entry(next, struct alloc_stat, |
| 371 | node); | 371 | node); |
| 372 | struct symbol *sym = NULL; | 372 | struct symbol *sym = NULL; |
| 373 | struct map_groups *kmaps = &machine->kmaps; | ||
| 374 | struct map *map; | 373 | struct map *map; |
| 375 | char buf[BUFSIZ]; | 374 | char buf[BUFSIZ]; |
| 376 | u64 addr; | 375 | u64 addr; |
| @@ -378,8 +377,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session, | |||
| 378 | if (is_caller) { | 377 | if (is_caller) { |
| 379 | addr = data->call_site; | 378 | addr = data->call_site; |
| 380 | if (!raw_ip) | 379 | if (!raw_ip) |
| 381 | sym = map_groups__find_function(kmaps, addr, | 380 | sym = machine__find_function(machine, addr, &map, NULL); |
| 382 | &map, NULL); | ||
| 383 | } else | 381 | } else |
| 384 | addr = data->ptr; | 382 | addr = data->ptr; |
| 385 | 383 | ||
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 7400e5147e13..1757b0ffeaa9 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
| @@ -429,9 +429,8 @@ static int event__process_kernel_mmap(event_t *self, | |||
| 429 | } else | 429 | } else |
| 430 | strcpy(short_module_name, self->mmap.filename); | 430 | strcpy(short_module_name, self->mmap.filename); |
| 431 | 431 | ||
| 432 | map = map_groups__new_module(&machine->kmaps, | 432 | map = machine__new_module(machine, self->mmap.start, |
| 433 | self->mmap.start, | 433 | self->mmap.filename); |
| 434 | self->mmap.filename, machine); | ||
| 435 | if (map == NULL) | 434 | if (map == NULL) |
| 436 | goto out_problem; | 435 | goto out_problem; |
| 437 | 436 | ||
| @@ -454,9 +453,7 @@ static int event__process_kernel_mmap(event_t *self, | |||
| 454 | goto out_problem; | 453 | goto out_problem; |
| 455 | 454 | ||
| 456 | kernel->kernel = kernel_type; | 455 | kernel->kernel = kernel_type; |
| 457 | if (__map_groups__create_kernel_maps(&machine->kmaps, | 456 | if (__machine__create_kernel_maps(machine, kernel) < 0) |
| 458 | machine->vmlinux_maps, | ||
| 459 | kernel) < 0) | ||
| 460 | goto out_problem; | 457 | goto out_problem; |
| 461 | 458 | ||
| 462 | event_set_kernel_mmap_len(machine->vmlinux_maps, self); | 459 | event_set_kernel_mmap_len(machine->vmlinux_maps, self); |
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c index ee25ee91504b..44a4df68b3cf 100644 --- a/tools/perf/util/map.c +++ b/tools/perf/util/map.c | |||
| @@ -513,6 +513,19 @@ struct map *maps__find(struct rb_root *maps, u64 ip) | |||
| 513 | return NULL; | 513 | return NULL; |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | int machine__init(struct machine *self, const char *root_dir, pid_t pid) | ||
| 517 | { | ||
| 518 | map_groups__init(&self->kmaps); | ||
| 519 | RB_CLEAR_NODE(&self->rb_node); | ||
| 520 | INIT_LIST_HEAD(&self->user_dsos); | ||
| 521 | INIT_LIST_HEAD(&self->kernel_dsos); | ||
| 522 | |||
| 523 | self->kmaps.machine = self; | ||
| 524 | self->pid = pid; | ||
| 525 | self->root_dir = strdup(root_dir); | ||
| 526 | return self->root_dir == NULL ? -ENOMEM : 0; | ||
| 527 | } | ||
| 528 | |||
| 516 | struct machine *machines__add(struct rb_root *self, pid_t pid, | 529 | struct machine *machines__add(struct rb_root *self, pid_t pid, |
| 517 | const char *root_dir) | 530 | const char *root_dir) |
| 518 | { | 531 | { |
| @@ -523,13 +536,10 @@ struct machine *machines__add(struct rb_root *self, pid_t pid, | |||
| 523 | if (!machine) | 536 | if (!machine) |
| 524 | return NULL; | 537 | return NULL; |
| 525 | 538 | ||
| 526 | machine->pid = pid; | 539 | if (machine__init(machine, root_dir, pid) != 0) { |
| 527 | map_groups__init(&machine->kmaps); | 540 | free(machine); |
| 528 | machine->root_dir = strdup(root_dir); | 541 | return NULL; |
| 529 | RB_CLEAR_NODE(&machine->rb_node); | 542 | } |
| 530 | INIT_LIST_HEAD(&machine->user_dsos); | ||
| 531 | INIT_LIST_HEAD(&machine->kernel_dsos); | ||
| 532 | machine->kmaps.machine = machine; | ||
| 533 | 543 | ||
| 534 | while (*p != NULL) { | 544 | while (*p != NULL) { |
| 535 | parent = *p; | 545 | parent = *p; |
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h index 6fabad1fd025..881dba4f8203 100644 --- a/tools/perf/util/map.h +++ b/tools/perf/util/map.h | |||
| @@ -134,6 +134,7 @@ struct machine *machines__find_host(struct rb_root *self); | |||
| 134 | struct machine *machines__find(struct rb_root *self, pid_t pid); | 134 | struct machine *machines__find(struct rb_root *self, pid_t pid); |
| 135 | struct machine *machines__findnew(struct rb_root *self, pid_t pid); | 135 | struct machine *machines__findnew(struct rb_root *self, pid_t pid); |
| 136 | char *machine__mmap_name(struct machine *self, char *bf, size_t size); | 136 | char *machine__mmap_name(struct machine *self, char *bf, size_t size); |
| 137 | int machine__init(struct machine *self, const char *root_dir, pid_t pid); | ||
| 137 | 138 | ||
| 138 | /* | 139 | /* |
| 139 | * Default guest kernel is defined by parameter --guestkallsyms | 140 | * Default guest kernel is defined by parameter --guestkallsyms |
| @@ -172,11 +173,11 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *self, | |||
| 172 | struct map **mapp, | 173 | struct map **mapp, |
| 173 | symbol_filter_t filter); | 174 | symbol_filter_t filter); |
| 174 | 175 | ||
| 175 | static inline | 176 | static inline struct symbol *machine__find_function(struct machine *self, |
| 176 | struct symbol *map_groups__find_function(struct map_groups *self, u64 addr, | 177 | u64 addr, struct map **mapp, |
| 177 | struct map **mapp, symbol_filter_t filter) | 178 | symbol_filter_t filter) |
| 178 | { | 179 | { |
| 179 | return map_groups__find_symbol(self, MAP__FUNCTION, addr, mapp, filter); | 180 | return map_groups__find_symbol(&self->kmaps, MAP__FUNCTION, addr, mapp, filter); |
| 180 | } | 181 | } |
| 181 | 182 | ||
| 182 | static inline | 183 | static inline |
| @@ -192,8 +193,7 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map, | |||
| 192 | 193 | ||
| 193 | struct map *map_groups__find_by_name(struct map_groups *self, | 194 | struct map *map_groups__find_by_name(struct map_groups *self, |
| 194 | enum map_type type, const char *name); | 195 | enum map_type type, const char *name); |
| 195 | struct map *map_groups__new_module(struct map_groups *self, u64 start, | 196 | struct map *machine__new_module(struct machine *self, u64 start, const char *filename); |
| 196 | const char *filename, struct machine *machine); | ||
| 197 | 197 | ||
| 198 | void map_groups__flush(struct map_groups *self); | 198 | void map_groups__flush(struct map_groups *self); |
| 199 | 199 | ||
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 9ded38ced234..914c67095d96 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
| @@ -72,8 +72,7 @@ static int e_snprintf(char *str, size_t size, const char *format, ...) | |||
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static char *synthesize_perf_probe_point(struct perf_probe_point *pp); | 74 | static char *synthesize_perf_probe_point(struct perf_probe_point *pp); |
| 75 | static struct map_groups kmap_groups; | 75 | static struct machine machine; |
| 76 | static struct map *kmaps[MAP__NR_TYPES]; | ||
| 77 | 76 | ||
| 78 | /* Initialize symbol maps and path of vmlinux */ | 77 | /* Initialize symbol maps and path of vmlinux */ |
| 79 | static int init_vmlinux(void) | 78 | static int init_vmlinux(void) |
| @@ -92,12 +91,15 @@ static int init_vmlinux(void) | |||
| 92 | goto out; | 91 | goto out; |
| 93 | } | 92 | } |
| 94 | 93 | ||
| 94 | ret = machine__init(&machine, "/", 0); | ||
| 95 | if (ret < 0) | ||
| 96 | goto out; | ||
| 97 | |||
| 95 | kernel = dso__new_kernel(symbol_conf.vmlinux_name); | 98 | kernel = dso__new_kernel(symbol_conf.vmlinux_name); |
| 96 | if (kernel == NULL) | 99 | if (kernel == NULL) |
| 97 | die("Failed to create kernel dso."); | 100 | die("Failed to create kernel dso."); |
| 98 | 101 | ||
| 99 | map_groups__init(&kmap_groups); | 102 | ret = __machine__create_kernel_maps(&machine, kernel); |
| 100 | ret = __map_groups__create_kernel_maps(&kmap_groups, kmaps, kernel); | ||
| 101 | if (ret < 0) | 103 | if (ret < 0) |
| 102 | pr_debug("Failed to create kernel maps.\n"); | 104 | pr_debug("Failed to create kernel maps.\n"); |
| 103 | 105 | ||
| @@ -110,12 +112,12 @@ out: | |||
| 110 | #ifdef DWARF_SUPPORT | 112 | #ifdef DWARF_SUPPORT |
| 111 | static int open_vmlinux(void) | 113 | static int open_vmlinux(void) |
| 112 | { | 114 | { |
| 113 | if (map__load(kmaps[MAP__FUNCTION], NULL) < 0) { | 115 | if (map__load(machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) { |
| 114 | pr_debug("Failed to load kernel map.\n"); | 116 | pr_debug("Failed to load kernel map.\n"); |
| 115 | return -EINVAL; | 117 | return -EINVAL; |
