aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-20 17:51:24 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-21 08:11:32 -0500
commit6671cb1674e69e2aba3d610714bdd3e97a7b51ff (patch)
tree61eb72c744c19086b272af4b3da21ef959ae35d5 /tools
parent96200591a34f8ecb98481c626125df43a2463b55 (diff)
perf symbols: Remove unrelated actions from dso__load_kernel_sym
It should just load kernel symbols, not load the list of modules. There are more stuff to move to other routines, but lets do it in several steps. End goal is to be able to defer symbol table loading till we find a hit for that map address range. So that the kernel & modules are handled just like all the other DSOs in the system. 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-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/builtin-annotate.c5
-rw-r--r--tools/perf/builtin-report.c3
-rw-r--r--tools/perf/builtin-top.c10
-rw-r--r--tools/perf/util/data_map.c2
-rw-r--r--tools/perf/util/symbol.c46
-rw-r--r--tools/perf/util/symbol.h7
6 files changed, 38 insertions, 35 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 77d50a6d6802..b6da1476ab1b 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -33,6 +33,7 @@ static int input;
33static int full_paths; 33static int full_paths;
34 34
35static int print_line; 35static int print_line;
36static bool use_modules;
36 37
37static unsigned long page_size; 38static unsigned long page_size;
38static unsigned long mmap_window = 32; 39static unsigned long mmap_window = 32;
@@ -636,7 +637,7 @@ static int __cmd_annotate(void)
636 exit(0); 637 exit(0);
637 } 638 }
638 639
639 if (load_kernel(symbol_filter) < 0) { 640 if (load_kernel(symbol_filter, use_modules) < 0) {
640 perror("failed to load kernel symbols"); 641 perror("failed to load kernel symbols");
641 return EXIT_FAILURE; 642 return EXIT_FAILURE;
642 } 643 }
@@ -742,7 +743,7 @@ static const struct option options[] = {
742 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 743 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
743 "dump raw trace in ASCII"), 744 "dump raw trace in ASCII"),
744 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), 745 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"),
745 OPT_BOOLEAN('m', "modules", &modules, 746 OPT_BOOLEAN('m', "modules", &use_modules,
746 "load module symbols - WARNING: use only with -k and LIVE kernel"), 747 "load module symbols - WARNING: use only with -k and LIVE kernel"),
747 OPT_BOOLEAN('l', "print-line", &print_line, 748 OPT_BOOLEAN('l', "print-line", &print_line,
748 "print matching source lines (may be slow)"), 749 "print matching source lines (may be slow)"),
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1a806d5f05cf..0af48401f089 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -38,6 +38,7 @@ static char *dso_list_str, *comm_list_str, *sym_list_str,
38static struct strlist *dso_list, *comm_list, *sym_list; 38static struct strlist *dso_list, *comm_list, *sym_list;
39 39
40static int force; 40static int force;
41static bool use_modules;
41 42
42static int full_paths; 43static int full_paths;
43static int show_nr_samples; 44static int show_nr_samples;
@@ -1023,7 +1024,7 @@ static const struct option options[] = {
1023 "dump raw trace in ASCII"), 1024 "dump raw trace in ASCII"),
1024 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), 1025 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"),
1025 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 1026 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
1026 OPT_BOOLEAN('m', "modules", &modules, 1027 OPT_BOOLEAN('m', "modules", &use_modules,
1027 "load module symbols - WARNING: use only with -k and LIVE kernel"), 1028 "load module symbols - WARNING: use only with -k and LIVE kernel"),
1028 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples, 1029 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples,
1029 "Show a column with the number of samples"), 1030 "Show a column with the number of samples"),
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 6d770ac7be0b..48cc1084bc30 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -953,8 +953,16 @@ static int parse_symbols(void)
953 if (kernel == NULL) 953 if (kernel == NULL)
954 return -1; 954 return -1;
955 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
956 if (dso__load_kernel_sym(kernel, symbol_filter, 1) <= 0) 963 if (dso__load_kernel_sym(kernel, symbol_filter, 1) <= 0)
957 return -1; 964 pr_debug("Couldn't read the complete list of kernel symbols, "
965 "continuing...\n");
958 966
959 if (dump_symtab) 967 if (dump_symtab)
960 dsos__fprintf(stderr); 968 dsos__fprintf(stderr);
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index 5543e7d0487d..a444a2645c85 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -171,7 +171,7 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
171 goto out_delete; 171 goto out_delete;
172 172
173 err = -ENOMEM; 173 err = -ENOMEM;
174 if (load_kernel(NULL) < 0) { 174 if (load_kernel(NULL, 1) < 0) {
175 pr_err("failed to load kernel symbols\n"); 175 pr_err("failed to load kernel symbols\n");
176 goto out_delete; 176 goto out_delete;
177 } 177 }
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 4d75e745288f..3b23c18cd36b 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1230,7 +1230,7 @@ failure:
1230 return -1; 1230 return -1;
1231} 1231}
1232 1232
1233static int dsos__load_modules_sym(symbol_filter_t filter) 1233int dsos__load_modules_sym(symbol_filter_t filter)
1234{ 1234{
1235 struct utsname uts; 1235 struct utsname uts;
1236 char modules_path[PATH_MAX]; 1236 char modules_path[PATH_MAX];
@@ -1352,33 +1352,18 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
1352 return err; 1352 return err;
1353} 1353}
1354 1354
1355int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int use_modules) 1355int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter,
1356 int use_modules)
1356{ 1357{
1357 int err = -1; 1358 int err;
1358 1359
1359 kernel_map = map__new2(0, self); 1360 kernel_map = map__new2(0, self);
1360 if (kernel_map == NULL) 1361 if (kernel_map == NULL)
1361 goto out_delete_dso; 1362 return -1;
1362 1363
1363 kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip; 1364 kernel_map->map_ip = kernel_map->unmap_ip = identity__map_ip;
1364 1365
1365 if (use_modules && dsos__load_modules() < 0) {
1366 pr_warning("Failed to load list of modules in use! "
1367 "Continuing...\n");
1368 use_modules = 0;
1369 }
1370
1371 err = dso__load_vmlinux(self, kernel_map, self->name, filter); 1366 err = dso__load_vmlinux(self, kernel_map, self->name, filter);
1372 if (err > 0 && use_modules) {
1373 int syms = dsos__load_modules_sym(filter);
1374
1375 if (syms < 0)
1376 pr_warning("Failed to read module symbols!"
1377 " Continuing...\n");
1378 else
1379 err += syms;
1380 }
1381
1382 if (err <= 0) 1367 if (err <= 0)
1383 err = kernel_maps__load_kallsyms(filter, use_modules); 1368 err = kernel_maps__load_kallsyms(filter, use_modules);
1384 1369
@@ -1404,17 +1389,12 @@ int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int use_modul
1404 } 1389 }
1405 1390
1406 return err; 1391 return err;
1407
1408out_delete_dso:
1409 dso__delete(self);
1410 return -1;
1411} 1392}
1412 1393
1413LIST_HEAD(dsos); 1394LIST_HEAD(dsos);
1414struct dso *vdso; 1395struct dso *vdso;
1415 1396
1416const char *vmlinux_name = "vmlinux"; 1397const char *vmlinux_name = "vmlinux";
1417int modules;
1418 1398
1419static void dsos__add(struct dso *dso) 1399static void dsos__add(struct dso *dso)
1420{ 1400{
@@ -1488,14 +1468,26 @@ struct dso *dsos__load_kernel(void)
1488 return kernel; 1468 return kernel;
1489} 1469}
1490 1470
1491int load_kernel(symbol_filter_t filter) 1471int load_kernel(symbol_filter_t filter, bool use_modules)
1492{ 1472{
1493 struct dso *kernel = dsos__load_kernel(); 1473 struct dso *kernel = dsos__load_kernel();
1494 1474
1495 if (kernel == NULL) 1475 if (kernel == NULL)
1496 return -1; 1476 return -1;
1497 1477
1498 return dso__load_kernel_sym(kernel, filter, modules); 1478 if (use_modules) {
1479 if (dsos__load_modules() < 0)
1480 pr_warning("Failed to load list of modules in use, "
1481 "continuing...\n");
1482 else if (dsos__load_modules_sym(filter) < 0)
1483 pr_warning("Failed to read module symbols, "
1484 "continuing...\n");
1485 }
1486
1487 if (dso__load_kernel_sym(kernel, filter, use_modules) < 0)
1488 pr_warning("Failed to read kernel symbols, continuing...\n");
1489
1490 return 0;
1499} 1491}
1500 1492
1501void symbol__init(unsigned int priv_size) 1493void symbol__init(unsigned int priv_size)
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index f0593a649c3d..3d9d346d101b 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -78,9 +78,11 @@ void dso__delete(struct dso *self);
78struct symbol *dso__find_symbol(struct dso *self, u64 ip); 78struct symbol *dso__find_symbol(struct dso *self, u64 ip);
79 79
80int dsos__load_modules(void); 80int dsos__load_modules(void);
81int dsos__load_modules_sym(symbol_filter_t filter);
81struct dso *dsos__findnew(const char *name); 82struct dso *dsos__findnew(const char *name);
82int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); 83int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
83int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter, int modules); 84int dso__load_kernel_sym(struct dso *self, symbol_filter_t filter,
85 int use_modules);
84void dsos__fprintf(FILE *fp); 86void dsos__fprintf(FILE *fp);
85size_t dsos__fprintf_buildid(FILE *fp); 87size_t dsos__fprintf_buildid(FILE *fp);
86 88
@@ -95,7 +97,7 @@ bool dsos__read_build_ids(void);
95int build_id__sprintf(u8 *self, int len, char *bf); 97int build_id__sprintf(u8 *self, int len, char *bf);
96 98
97struct dso *dsos__load_kernel(void); 99struct dso *dsos__load_kernel(void);
98int load_kernel(symbol_filter_t filter); 100int load_kernel(symbol_filter_t filter, bool use_modules);
99 101
100void symbol__init(unsigned int priv_size); 102void symbol__init(unsigned int priv_size);
101 103
@@ -103,5 +105,4 @@ extern struct list_head dsos;
103extern struct map *kernel_map; 105extern struct map *kernel_map;
104extern struct dso *vdso; 106extern struct dso *vdso;
105extern const char *vmlinux_name; 107extern const char *vmlinux_name;
106extern int modules;
107#endif /* __PERF_SYMBOL */ 108#endif /* __PERF_SYMBOL */