diff options
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r-- | tools/perf/builtin-top.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c index 3af95203208a..89b7f68a1799 100644 --- a/tools/perf/builtin-top.c +++ b/tools/perf/builtin-top.c | |||
@@ -76,6 +76,9 @@ static int delay_secs = 2; | |||
76 | static int zero = 0; | 76 | static int zero = 0; |
77 | static int dump_symtab = 0; | 77 | static int dump_symtab = 0; |
78 | 78 | ||
79 | static bool hide_kernel_symbols = false; | ||
80 | static bool hide_user_symbols = false; | ||
81 | |||
79 | /* | 82 | /* |
80 | * Source | 83 | * Source |
81 | */ | 84 | */ |
@@ -104,6 +107,7 @@ struct sym_entry { | |||
104 | unsigned long snap_count; | 107 | unsigned long snap_count; |
105 | double weight; | 108 | double weight; |
106 | int skip; | 109 | int skip; |
110 | u8 origin; | ||
107 | struct map *map; | 111 | struct map *map; |
108 | struct source_line *source; | 112 | struct source_line *source; |
109 | struct source_line *lines; | 113 | struct source_line *lines; |
@@ -430,6 +434,13 @@ static void print_sym_table(void) | |||
430 | list_for_each_entry_safe_from(syme, n, &active_symbols, node) { | 434 | list_for_each_entry_safe_from(syme, n, &active_symbols, node) { |
431 | syme->snap_count = syme->count[snap]; | 435 | syme->snap_count = syme->count[snap]; |
432 | if (syme->snap_count != 0) { | 436 | if (syme->snap_count != 0) { |
437 | if ((hide_user_symbols && | ||
438 | syme->origin == PERF_RECORD_MISC_USER) || | ||
439 | (hide_kernel_symbols && | ||
440 | syme->origin == PERF_RECORD_MISC_KERNEL)) { | ||
441 | list_remove_active_sym(syme); | ||
442 | continue; | ||
443 | } | ||
433 | syme->weight = sym_weight(syme); | 444 | syme->weight = sym_weight(syme); |
434 | rb_insert_active_sym(&tmp, syme); | 445 | rb_insert_active_sym(&tmp, syme); |
435 | sum_ksamples += syme->snap_count; | 446 | sum_ksamples += syme->snap_count; |
@@ -637,6 +648,12 @@ static void print_mapped_keys(void) | |||
637 | if (nr_counters > 1) | 648 | if (nr_counters > 1) |
638 | fprintf(stdout, "\t[w] toggle display weighted/count[E]r. \t(%d)\n", display_weighted ? 1 : 0); | 649 | fprintf(stdout, "\t[w] toggle display weighted/count[E]r. \t(%d)\n", display_weighted ? 1 : 0); |
639 | 650 | ||
651 | fprintf(stdout, | ||
652 | "\t[K] hide kernel_symbols symbols. \t(%s)\n", | ||
653 | hide_kernel_symbols ? "yes" : "no"); | ||
654 | fprintf(stdout, | ||
655 | "\t[U] hide user symbols. \t(%s)\n", | ||
656 | hide_user_symbols ? "yes" : "no"); | ||
640 | fprintf(stdout, "\t[z] toggle sample zeroing. \t(%d)\n", zero ? 1 : 0); | 657 | fprintf(stdout, "\t[z] toggle sample zeroing. \t(%d)\n", zero ? 1 : 0); |
641 | fprintf(stdout, "\t[qQ] quit.\n"); | 658 | fprintf(stdout, "\t[qQ] quit.\n"); |
642 | } | 659 | } |
@@ -650,6 +667,8 @@ static int key_mapped(int c) | |||
650 | case 'z': | 667 | case 'z': |
651 | case 'q': | 668 | case 'q': |
652 | case 'Q': | 669 | case 'Q': |
670 | case 'K': | ||
671 | case 'U': | ||
653 | return 1; | 672 | return 1; |
654 | case 'E': | 673 | case 'E': |
655 | case 'w': | 674 | case 'w': |
@@ -727,6 +746,9 @@ static void handle_keypress(int c) | |||
727 | case 'F': | 746 | case 'F': |
728 | prompt_percent(&sym_pcnt_filter, "Enter details display event filter (percent)"); | 747 | prompt_percent(&sym_pcnt_filter, "Enter details display event filter (percent)"); |
729 | break; | 748 | break; |
749 | case 'K': | ||
750 | hide_kernel_symbols = !hide_kernel_symbols; | ||
751 | break; | ||
730 | case 'q': | 752 | case 'q': |
731 | case 'Q': | 753 | case 'Q': |
732 | printf("exiting.\n"); | 754 | printf("exiting.\n"); |
@@ -746,6 +768,9 @@ static void handle_keypress(int c) | |||
746 | pthread_mutex_unlock(&syme->source_lock); | 768 | pthread_mutex_unlock(&syme->source_lock); |
747 | } | 769 | } |
748 | break; | 770 | break; |
771 | case 'U': | ||
772 | hide_user_symbols = !hide_user_symbols; | ||
773 | break; | ||
749 | case 'w': | 774 | case 'w': |
750 | display_weighted = ~display_weighted; | 775 | display_weighted = ~display_weighted; |
751 | break; | 776 | break; |
@@ -857,11 +882,16 @@ static void event__process_sample(const event_t *self, int counter) | |||
857 | struct map *map; | 882 | struct map *map; |
858 | struct sym_entry *syme; | 883 | struct sym_entry *syme; |
859 | struct symbol *sym; | 884 | struct symbol *sym; |
885 | u8 origin = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK; | ||
860 | 886 | ||
861 | switch (self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK) { | 887 | switch (origin) { |
862 | case PERF_RECORD_MISC_USER: { | 888 | case PERF_RECORD_MISC_USER: { |
863 | struct thread *thread = threads__findnew(self->ip.pid); | 889 | struct thread *thread; |
864 | 890 | ||
891 | if (hide_user_symbols) | ||
892 | return; | ||
893 | |||
894 | thread = threads__findnew(self->ip.pid); | ||
865 | if (thread == NULL) | 895 | if (thread == NULL) |
866 | return; | 896 | return; |
867 | 897 | ||
@@ -885,6 +915,9 @@ static void event__process_sample(const event_t *self, int counter) | |||
885 | return; | 915 | return; |
886 | /* Fall thru */ | 916 | /* Fall thru */ |
887 | case PERF_RECORD_MISC_KERNEL: | 917 | case PERF_RECORD_MISC_KERNEL: |
918 | if (hide_kernel_symbols) | ||
919 | return; | ||
920 | |||
888 | sym = kernel_maps__find_symbol(ip, &map); | 921 | sym = kernel_maps__find_symbol(ip, &map); |
889 | if (sym == NULL) | 922 | if (sym == NULL) |
890 | return; | 923 | return; |
@@ -897,6 +930,7 @@ static void event__process_sample(const event_t *self, int counter) | |||
897 | 930 | ||
898 | if (!syme->skip) { | 931 | if (!syme->skip) { |
899 | syme->count[counter]++; | 932 | syme->count[counter]++; |
933 | syme->origin = origin; | ||
900 | record_precise_ip(syme, counter, ip); | 934 | record_precise_ip(syme, counter, ip); |
901 | pthread_mutex_lock(&active_symbols_lock); | 935 | pthread_mutex_lock(&active_symbols_lock); |
902 | if (list_empty(&syme->node) || !syme->node.next) | 936 | if (list_empty(&syme->node) || !syme->node.next) |
@@ -1178,6 +1212,8 @@ static const struct option options[] = { | |||
1178 | OPT_INTEGER('C', "CPU", &profile_cpu, | 1212 | OPT_INTEGER('C', "CPU", &profile_cpu, |
1179 | "CPU to profile on"), | 1213 | "CPU to profile on"), |
1180 | OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), | 1214 | OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), |
1215 | OPT_BOOLEAN('K', "hide_kernel_symbols", &hide_kernel_symbols, | ||
1216 | "hide kernel symbols"), | ||
1181 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, | 1217 | OPT_INTEGER('m', "mmap-pages", &mmap_pages, |
1182 | "number of mmap data pages"), | 1218 | "number of mmap data pages"), |
1183 | OPT_INTEGER('r', "realtime", &realtime_prio, | 1219 | OPT_INTEGER('r', "realtime", &realtime_prio, |
@@ -1200,6 +1236,8 @@ static const struct option options[] = { | |||
1200 | "profile at this frequency"), | 1236 | "profile at this frequency"), |
1201 | OPT_INTEGER('E', "entries", &print_entries, | 1237 | OPT_INTEGER('E', "entries", &print_entries, |
1202 | "display this many functions"), | 1238 | "display this many functions"), |
1239 | OPT_BOOLEAN('U', "hide_user_symbols", &hide_user_symbols, | ||
1240 | "hide user symbols"), | ||
1203 | OPT_BOOLEAN('v', "verbose", &verbose, | 1241 | OPT_BOOLEAN('v', "verbose", &verbose, |
1204 | "be more verbose (show counter open errors, etc)"), | 1242 | "be more verbose (show counter open errors, etc)"), |
1205 | OPT_END() | 1243 | OPT_END() |