diff options
-rw-r--r-- | tools/perf/builtin-top.c | 3 | ||||
-rw-r--r-- | tools/perf/util/symbol-elf.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 32 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 2 |
4 files changed, 25 insertions, 14 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index e0919006fcba..6f48df14e277 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -679,9 +679,6 @@ static int symbol_filter(struct map *map, struct symbol *sym) | |||
679 | strstr(name, "_text_end")) | 679 | strstr(name, "_text_end")) |
680 | return 1; | 680 | return 1; |
681 | 681 | ||
682 | if (symbol__is_idle(sym)) | ||
683 | sym->idle = 1; | ||
684 | |||
685 | return 0; | 682 | return 0; |
686 | } | 683 | } |
687 | 684 | ||
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index 295d3147a803..bd91a4f67080 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c | |||
@@ -1127,7 +1127,7 @@ new_symbol: | |||
1127 | if (filter && filter(curr_map, f)) | 1127 | if (filter && filter(curr_map, f)) |
1128 | symbol__delete(f); | 1128 | symbol__delete(f); |
1129 | else { | 1129 | else { |
1130 | symbols__insert(&curr_dso->symbols[curr_map->type], f); | 1130 | __symbols__insert(&curr_dso->symbols[curr_map->type], f, dso->kernel); |
1131 | nr++; | 1131 | nr++; |
1132 | } | 1132 | } |
1133 | } | 1133 | } |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index 98cd50384c32..4c5788f30ced 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -28,6 +28,8 @@ static int dso__load_kernel_sym(struct dso *dso, struct map *map, | |||
28 | symbol_filter_t filter); | 28 | symbol_filter_t filter); |
29 | static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map, | 29 | static int dso__load_guest_kernel_sym(struct dso *dso, struct map *map, |
30 | symbol_filter_t filter); | 30 | symbol_filter_t filter); |
31 | static bool symbol__is_idle(const char *name); | ||
32 | |||
31 | int vmlinux_path__nr_entries; | 33 | int vmlinux_path__nr_entries; |
32 | char **vmlinux_path; | 34 | char **vmlinux_path; |
33 | 35 | ||
@@ -277,13 +279,24 @@ void symbols__delete(struct rb_root *symbols) | |||
277 | } | 279 | } |
278 | } | 280 | } |
279 | 281 | ||
280 | void symbols__insert(struct rb_root *symbols, struct symbol *sym) | 282 | void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel) |
281 | { | 283 | { |
282 | struct rb_node **p = &symbols->rb_node; | 284 | struct rb_node **p = &symbols->rb_node; |
283 | struct rb_node *parent = NULL; | 285 | struct rb_node *parent = NULL; |
284 | const u64 ip = sym->start; | 286 | const u64 ip = sym->start; |
285 | struct symbol *s; | 287 | struct symbol *s; |
286 | 288 | ||
289 | if (kernel) { | ||
290 | const char *name = sym->name; | ||
291 | /* | ||
292 | * ppc64 uses function descriptors and appends a '.' to the | ||
293 | * start of every instruction address. Remove it. | ||
294 | */ | ||
295 | if (name[0] == '.') | ||
296 | name++; | ||
297 | sym->idle = symbol__is_idle(name); | ||
298 | } | ||
299 | |||
287 | while (*p != NULL) { | 300 | while (*p != NULL) { |
288 | parent = *p; | 301 | parent = *p; |
289 | s = rb_entry(parent, struct symbol, rb_node); | 302 | s = rb_entry(parent, struct symbol, rb_node); |
@@ -296,6 +309,11 @@ void symbols__insert(struct rb_root *symbols, struct symbol *sym) | |||
296 | rb_insert_color(&sym->rb_node, symbols); | 309 | rb_insert_color(&sym->rb_node, symbols); |
297 | } | 310 | } |
298 | 311 | ||
312 | void symbols__insert(struct rb_root *symbols, struct symbol *sym) | ||
313 | { | ||
314 | __symbols__insert(symbols, sym, false); | ||
315 | } | ||
316 | |||
299 | static struct symbol *symbols__find(struct rb_root *symbols, u64 ip) | 317 | static struct symbol *symbols__find(struct rb_root *symbols, u64 ip) |
300 | { | 318 | { |
301 | struct rb_node *n; | 319 | struct rb_node *n; |
@@ -424,7 +442,7 @@ void dso__reset_find_symbol_cache(struct dso *dso) | |||
424 | 442 | ||
425 | void dso__insert_symbol(struct dso *dso, enum map_type type, struct symbol *sym) | 443 | void dso__insert_symbol(struct dso *dso, enum map_type type, struct symbol *sym) |
426 | { | 444 | { |
427 | symbols__insert(&dso->symbols[type], sym); | 445 | __symbols__insert(&dso->symbols[type], sym, dso->kernel); |
428 | 446 | ||
429 | /* update the symbol cache if necessary */ | 447 | /* update the symbol cache if necessary */ |
430 | if (dso->last_find_result[type].addr >= sym->start && | 448 | if (dso->last_find_result[type].addr >= sym->start && |
@@ -546,7 +564,7 @@ struct process_kallsyms_args { | |||
546 | * These are symbols in the kernel image, so make sure that | 564 | * These are symbols in the kernel image, so make sure that |
547 | * sym is from a kernel DSO. | 565 | * sym is from a kernel DSO. |
548 | */ | 566 | */ |
549 | bool symbol__is_idle(struct symbol *sym) | 567 | static bool symbol__is_idle(const char *name) |
550 | { | 568 | { |
551 | const char * const idle_symbols[] = { | 569 | const char * const idle_symbols[] = { |
552 | "cpu_idle", | 570 | "cpu_idle", |
@@ -563,14 +581,10 @@ bool symbol__is_idle(struct symbol *sym) | |||
563 | "pseries_dedicated_idle_sleep", | 581 | "pseries_dedicated_idle_sleep", |
564 | NULL | 582 | NULL |
565 | }; | 583 | }; |
566 | |||
567 | int i; | 584 | int i; |
568 | 585 | ||
569 | if (!sym) | ||
570 | return false; | ||
571 | |||
572 | for (i = 0; idle_symbols[i]; i++) { | 586 | for (i = 0; idle_symbols[i]; i++) { |
573 | if (!strcmp(idle_symbols[i], sym->name)) | 587 | if (!strcmp(idle_symbols[i], name)) |
574 | return true; | 588 | return true; |
575 | } | 589 | } |
576 | 590 | ||
@@ -599,7 +613,7 @@ static int map__process_kallsym_symbol(void *arg, const char *name, | |||
599 | * We will pass the symbols to the filter later, in | 613 | * We will pass the symbols to the filter later, in |
600 | * map__split_kallsyms, when we have split the maps per module | 614 | * map__split_kallsyms, when we have split the maps per module |
601 | */ | 615 | */ |
602 | symbols__insert(root, sym); | 616 | __symbols__insert(root, sym, !strchr(name, '[')); |
603 | 617 | ||
604 | return 0; | 618 | return 0; |
605 | } | 619 | } |
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index e54ee7c78ca3..72d29312a694 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -294,7 +294,6 @@ size_t symbol__fprintf(struct symbol *sym, FILE *fp); | |||
294 | bool symbol_type__is_a(char symbol_type, enum map_type map_type); | 294 | bool symbol_type__is_a(char symbol_type, enum map_type map_type); |
295 | bool symbol__restricted_filename(const char *filename, | 295 | bool symbol__restricted_filename(const char *filename, |
296 | const char *restricted_filename); | 296 | const char *restricted_filename); |
297 | bool symbol__is_idle(struct symbol *sym); | ||
298 | int symbol__config_symfs(const struct option *opt __maybe_unused, | 297 | int symbol__config_symfs(const struct option *opt __maybe_unused, |
299 | const char *dir, int unset __maybe_unused); | 298 | const char *dir, int unset __maybe_unused); |
300 | 299 | ||
@@ -304,6 +303,7 @@ int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *syms_ss, | |||
304 | int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, | 303 | int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss, |
305 | struct map *map, symbol_filter_t filter); | 304 | struct map *map, symbol_filter_t filter); |
306 | 305 | ||
306 | void __symbols__insert(struct rb_root *symbols, struct symbol *sym, bool kernel); | ||
307 | void symbols__insert(struct rb_root *symbols, struct symbol *sym); | 307 | void symbols__insert(struct rb_root *symbols, struct symbol *sym); |
308 | void symbols__fixup_duplicate(struct rb_root *symbols); | 308 | void symbols__fixup_duplicate(struct rb_root *symbols); |
309 | void symbols__fixup_end(struct rb_root *symbols); | 309 | void symbols__fixup_end(struct rb_root *symbols); |