diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-12-16 05:22:25 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-12-16 05:22:27 -0500 |
commit | 006b20fe4c69189b0d854e5eabf269e50ca86cdd (patch) | |
tree | 948b08825a36114c85ddc2bfcd965c261e32810f /tools/perf/util | |
parent | 5f29805a4f4627e766f862ff9f10c14f5f314359 (diff) | |
parent | d949750fed168b6553ca11ed19e4affd19d7a4d7 (diff) |
Merge branch 'perf/urgent' into perf/core
Merge reason: We want to apply a dependent patch.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/header.c | 11 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 59 |
2 files changed, 61 insertions, 9 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 76e949a59ea4..16a16021eaa6 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -971,11 +971,16 @@ perf_header__find_attr(u64 id, struct perf_header *header) | |||
971 | 971 | ||
972 | /* | 972 | /* |
973 | * We set id to -1 if the data file doesn't contain sample | 973 | * We set id to -1 if the data file doesn't contain sample |
974 | * ids. Check for this and avoid walking through the entire | 974 | * ids. This can happen when the data file contains one type |
975 | * list of ids which may be large. | 975 | * of event and in that case, the header can still store the |
976 | * event attribute information. Check for this and avoid | ||
977 | * walking through the entire list of ids which may be large. | ||
976 | */ | 978 | */ |
977 | if (id == -1ULL) | 979 | if (id == -1ULL) { |
980 | if (header->attrs > 0) | ||
981 | return &header->attr[0]->attr; | ||
978 | return NULL; | 982 | return NULL; |
983 | } | ||
979 | 984 | ||
980 | for (i = 0; i < header->attrs; i++) { | 985 | for (i = 0; i < header->attrs; i++) { |
981 | struct perf_header_attr *attr = header->attr[i]; | 986 | struct perf_header_attr *attr = header->attr[i]; |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index f40c076aeb7b..ceefa6568def 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -532,7 +532,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
532 | struct machine *machine = kmaps->machine; | 532 | struct machine *machine = kmaps->machine; |
533 | struct map *curr_map = map; | 533 | struct map *curr_map = map; |
534 | struct symbol *pos; | 534 | struct symbol *pos; |
535 | int count = 0; | 535 | int count = 0, moved = 0; |
536 | struct rb_root *root = &self->symbols[map->type]; | 536 | struct rb_root *root = &self->symbols[map->type]; |
537 | struct rb_node *next = rb_first(root); | 537 | struct rb_node *next = rb_first(root); |
538 | int kernel_range = 0; | 538 | int kernel_range = 0; |
@@ -590,6 +590,11 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
590 | char dso_name[PATH_MAX]; | 590 | char dso_name[PATH_MAX]; |
591 | struct dso *dso; | 591 | struct dso *dso; |
592 | 592 | ||
593 | if (count == 0) { | ||
594 | curr_map = map; | ||
595 | goto filter_symbol; | ||
596 | } | ||
597 | |||
593 | if (self->kernel == DSO_TYPE_GUEST_KERNEL) | 598 | if (self->kernel == DSO_TYPE_GUEST_KERNEL) |
594 | snprintf(dso_name, sizeof(dso_name), | 599 | snprintf(dso_name, sizeof(dso_name), |
595 | "[guest.kernel].%d", | 600 | "[guest.kernel].%d", |
@@ -615,7 +620,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
615 | map_groups__insert(kmaps, curr_map); | 620 | map_groups__insert(kmaps, curr_map); |
616 | ++kernel_range; | 621 | ++kernel_range; |
617 | } | 622 | } |
618 | 623 | filter_symbol: | |
619 | if (filter && filter(curr_map, pos)) { | 624 | if (filter && filter(curr_map, pos)) { |
620 | discard_symbol: rb_erase(&pos->rb_node, root); | 625 | discard_symbol: rb_erase(&pos->rb_node, root); |
621 | symbol__delete(pos); | 626 | symbol__delete(pos); |
@@ -623,8 +628,9 @@ discard_symbol: rb_erase(&pos->rb_node, root); | |||
623 | if (curr_map != map) { | 628 | if (curr_map != map) { |
624 | rb_erase(&pos->rb_node, root); | 629 | rb_erase(&pos->rb_node, root); |
625 | symbols__insert(&curr_map->dso->symbols[curr_map->type], pos); | 630 | symbols__insert(&curr_map->dso->symbols[curr_map->type], pos); |
626 | } | 631 | ++moved; |
627 | count++; | 632 | } else |
633 | ++count; | ||
628 | } | 634 | } |
629 | } | 635 | } |
630 | 636 | ||
@@ -634,7 +640,7 @@ discard_symbol: rb_erase(&pos->rb_node, root); | |||
634 | dso__set_loaded(curr_map->dso, curr_map->type); | 640 | dso__set_loaded(curr_map->dso, curr_map->type); |
635 | } | 641 | } |
636 | 642 | ||
637 | return count; | 643 | return count + moved; |
638 | } | 644 | } |
639 | 645 | ||
640 | int dso__load_kallsyms(struct dso *self, const char *filename, | 646 | int dso__load_kallsyms(struct dso *self, const char *filename, |
@@ -2130,14 +2136,55 @@ static struct dso *machine__create_kernel(struct machine *self) | |||
2130 | return kernel; | 2136 | return kernel; |
2131 | } | 2137 | } |
2132 | 2138 | ||
2139 | struct process_args { | ||
2140 | u64 start; | ||
2141 | }; | ||
2142 | |||
2143 | static int symbol__in_kernel(void *arg, const char *name, | ||
2144 | char type __used, u64 start) | ||
2145 | { | ||
2146 | struct process_args *args = arg; | ||
2147 | |||
2148 | if (strchr(name, '[')) | ||
2149 | return 0; | ||
2150 | |||
2151 | args->start = start; | ||
2152 | return 1; | ||
2153 | } | ||
2154 | |||
2155 | /* Figure out the start address of kernel map from /proc/kallsyms */ | ||
2156 | static u64 machine__get_kernel_start_addr(struct machine *machine) | ||
2157 | { | ||
2158 | const char *filename; | ||
2159 | char path[PATH_MAX]; | ||
2160 | struct process_args args; | ||
2161 | |||
2162 | if (machine__is_host(machine)) { | ||
2163 | filename = "/proc/kallsyms"; | ||
2164 | } else { | ||
2165 | if (machine__is_default_guest(machine)) | ||
2166 | filename = (char *)symbol_conf.default_guest_kallsyms; | ||
2167 | else { | ||
2168 | sprintf(path, "%s/proc/kallsyms", machine->root_dir); | ||
2169 | filename = path; | ||
2170 | } | ||
2171 | } | ||
2172 | |||
2173 | if (kallsyms__parse(filename, &args, symbol__in_kernel) <= 0) | ||
2174 | return 0; | ||
2175 | |||
2176 | return args.start; | ||
2177 | } | ||
2178 | |||
2133 | int __machine__create_kernel_maps(struct machine *self, struct dso *kernel) | 2179 | int __machine__create_kernel_maps(struct machine *self, struct dso *kernel) |
2134 | { | 2180 | { |
2135 | enum map_type type; | 2181 | enum map_type type; |
2182 | u64 start = machine__get_kernel_start_addr(self); | ||
2136 | 2183 | ||
2137 | for (type = 0; type < MAP__NR_TYPES; ++type) { | 2184 | for (type = 0; type < MAP__NR_TYPES; ++type) { |
2138 | struct kmap *kmap; | 2185 | struct kmap *kmap; |
2139 | 2186 | ||
2140 | self->vmlinux_maps[type] = map__new2(0, kernel, type); | 2187 | self->vmlinux_maps[type] = map__new2(start, kernel, type); |
2141 | if (self->vmlinux_maps[type] == NULL) | 2188 | if (self->vmlinux_maps[type] == NULL) |
2142 | return -1; | 2189 | return -1; |
2143 | 2190 | ||