aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-top.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-20 17:51:27 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-21 08:11:33 -0500
commitc338aee853db197e1855b393e6d6cc667784537f (patch)
treef97fea21c608a689144302b8dd78ef29bfaa5c88 /tools/perf/builtin-top.c
parent78075caad99dc36ec6ef5826b7a5273ea14295fc (diff)
perf symbols: Do lazy symtab loading for the kernel & modules too
Just like we do with the other DSOs. This also simplifies the kernel_maps setup process, now all that the tools need to do is to call kernel_maps__init and the maps for the modules and kernel will be created, then, later, when kernel_maps__find_symbol() is used, it will also call maps__find_symbol that already checks if the symtab was loaded, loading it if needed. Now if one does 'perf top --hide_kernel_symbols' we won't pay the price of loading the (many) symbols in /proc/kallsyms or vmlinux. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> LKML-Reference: <1258757489-5978-4-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/builtin-top.c')
-rw-r--r--tools/perf/builtin-top.c35
1 files changed, 7 insertions, 28 deletions
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 48cc1084bc30..ea49c2e9dda3 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -830,6 +830,8 @@ static void handle_keypress(int c)
830 case 'q': 830 case 'q':
831 case 'Q': 831 case 'Q':
832 printf("exiting.\n"); 832 printf("exiting.\n");
833 if (dump_symtab)
834 dsos__fprintf(stderr);
833 exit(0); 835 exit(0);
834 case 's': 836 case 's':
835 prompt_symbol(&sym_filter_entry, "Enter details symbol"); 837 prompt_symbol(&sym_filter_entry, "Enter details symbol");
@@ -946,30 +948,6 @@ static int symbol_filter(struct map *map, struct symbol *sym)
946 return 0; 948 return 0;
947} 949}
948 950
949static int parse_symbols(void)
950{
951 struct dso *kernel = dsos__load_kernel();
952
953 if (kernel == NULL)
954 return -1;
955
956 if (dsos__load_modules() < 0)
957 pr_debug("Couldn't read the complete list of modules, "
958 "continuing...\n");
959
960 if (dsos__load_modules_sym(symbol_filter) < 0)
961 pr_warning("Failed to read module symbols, continuing...\n");
962
963 if (dso__load_kernel_sym(kernel, symbol_filter, 1) <= 0)
964 pr_debug("Couldn't read the complete list of kernel symbols, "
965 "continuing...\n");
966
967 if (dump_symtab)
968 dsos__fprintf(stderr);
969
970 return 0;
971}
972
973static void event__process_sample(const event_t *self, int counter) 951static void event__process_sample(const event_t *self, int counter)
974{ 952{
975 u64 ip = self->ip.ip; 953 u64 ip = self->ip.ip;
@@ -1012,7 +990,7 @@ static void event__process_sample(const event_t *self, int counter)
1012 if (hide_kernel_symbols) 990 if (hide_kernel_symbols)
1013 return; 991 return;
1014 992
1015 sym = kernel_maps__find_symbol(ip, &map); 993 sym = kernel_maps__find_symbol(ip, &map, symbol_filter);
1016 if (sym == NULL) 994 if (sym == NULL)
1017 return; 995 return;
1018 break; 996 break;
@@ -1339,7 +1317,7 @@ static const struct option options[] = {
1339 1317
1340int cmd_top(int argc, const char **argv, const char *prefix __used) 1318int cmd_top(int argc, const char **argv, const char *prefix __used)
1341{ 1319{
1342 int counter; 1320 int counter, err;
1343 1321
1344 page_size = sysconf(_SC_PAGE_SIZE); 1322 page_size = sysconf(_SC_PAGE_SIZE);
1345 1323
@@ -1363,10 +1341,11 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1363 if (delay_secs < 1) 1341 if (delay_secs < 1)
1364 delay_secs = 1; 1342 delay_secs = 1;
1365 1343
1366 parse_symbols(); 1344 err = kernel_maps__init(true);
1345 if (err < 0)
1346 return err;
1367 parse_source(sym_filter_entry); 1347 parse_source(sym_filter_entry);
1368 1348
1369
1370 /* 1349 /*
1371 * User specified count overrides default frequency. 1350 * User specified count overrides default frequency.
1372 */ 1351 */