aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2009-11-24 09:05:15 -0500
committerIngo Molnar <mingo@elte.hu>2009-11-24 10:37:02 -0500
commitb32d133aec5dc882cf783a293f393bfb3f4379e1 (patch)
tree41fc56a4aaec8892a235ffd530b36278d147dc4e /tools
parent7cc017edb9459193d3b581155a14029e4bef0c49 (diff)
perf symbols: Simplify symbol machinery setup
And also express its configuration toggles via a struct. Now all one has to do is to call symbol__init(NULL) if the defaults are OK, or pass a struct symbol_conf pointer with the desired configuration. If a tool uses kernel_maps__find_symbol() to look at the kernel and modules mappings for a symbol but didn't call symbol__init() first, that will generate a one time warning too, alerting the subcommand developer that symbol__init() must be called. 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: <1259071517-3242-2-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.c20
-rw-r--r--tools/perf/builtin-kmem.c2
-rw-r--r--tools/perf/builtin-report.c15
-rw-r--r--tools/perf/builtin-sched.c2
-rw-r--r--tools/perf/builtin-top.c24
-rw-r--r--tools/perf/builtin-trace.c2
-rw-r--r--tools/perf/util/data_map.c8
-rw-r--r--tools/perf/util/data_map.h2
-rw-r--r--tools/perf/util/header.c6
-rw-r--r--tools/perf/util/include/asm/bug.h22
-rw-r--r--tools/perf/util/symbol.c31
-rw-r--r--tools/perf/util/symbol.h11
12 files changed, 85 insertions, 60 deletions
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 59b6123abec2..cd97c2b1cc3b 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -34,11 +34,9 @@ static int input;
34static int full_paths; 34static int full_paths;
35 35
36static int print_line; 36static int print_line;
37static bool use_modules;
38 37
39static unsigned long page_size; 38static unsigned long page_size;
40static unsigned long mmap_window = 32; 39static unsigned long mmap_window = 32;
41const char *vmlinux_name;
42 40
43struct sym_hist { 41struct sym_hist {
44 u64 sum; 42 u64 sum;
@@ -56,6 +54,11 @@ struct sym_priv {
56 struct sym_ext *ext; 54 struct sym_ext *ext;
57}; 55};
58 56
57static struct symbol_conf symbol_conf = {
58 .priv_size = sizeof(struct sym_priv),
59 .try_vmlinux_path = true,
60};
61
59static const char *sym_hist_filter; 62static const char *sym_hist_filter;
60 63
61static int symbol_filter(struct map *map __used, struct symbol *sym) 64static int symbol_filter(struct map *map __used, struct symbol *sym)
@@ -586,11 +589,6 @@ static int __cmd_annotate(void)
586 exit(0); 589 exit(0);
587 } 590 }
588 591
589 if (kernel_maps__init(vmlinux_name, true, use_modules) < 0) {
590 pr_err("failed to create kernel maps for symbol resolution\b");
591 return -1;
592 }
593
594remap: 592remap:
595 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ, 593 buf = (char *)mmap(NULL, page_size * mmap_window, PROT_READ,
596 MAP_SHARED, input, offset); 594 MAP_SHARED, input, offset);
@@ -691,8 +689,9 @@ static const struct option options[] = {
691 "be more verbose (show symbol address, etc)"), 689 "be more verbose (show symbol address, etc)"),
692 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 690 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
693 "dump raw trace in ASCII"), 691 "dump raw trace in ASCII"),
694 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), 692 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
695 OPT_BOOLEAN('m', "modules", &use_modules, 693 "file", "vmlinux pathname"),
694 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
696 "load module symbols - WARNING: use only with -k and LIVE kernel"), 695 "load module symbols - WARNING: use only with -k and LIVE kernel"),
697 OPT_BOOLEAN('l', "print-line", &print_line, 696 OPT_BOOLEAN('l', "print-line", &print_line,
698 "print matching source lines (may be slow)"), 697 "print matching source lines (may be slow)"),
@@ -718,7 +717,8 @@ static void setup_sorting(void)
718 717
719int cmd_annotate(int argc, const char **argv, const char *prefix __used) 718int cmd_annotate(int argc, const char **argv, const char *prefix __used)
720{ 719{
721 symbol__init(sizeof(struct sym_priv)); 720 if (symbol__init(&symbol_conf) < 0)
721 return -1;
722 722
723 page_size = getpagesize(); 723 page_size = getpagesize();
724 724
diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 173d6db42ecb..330dbc762f9e 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -412,7 +412,7 @@ static int read_events(void)
412 register_idle_thread(); 412 register_idle_thread();
413 register_perf_file_handler(&file_handler); 413 register_perf_file_handler(&file_handler);
414 414
415 return mmap_dispatch_perf_file(&header, input_name, NULL, false, 0, 0, 415 return mmap_dispatch_perf_file(&header, input_name, 0, 0,
416 &cwdlen, &cwd); 416 &cwdlen, &cwd);
417} 417}
418 418
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 1826be719b58..0ee3d05a0409 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -39,7 +39,6 @@ static char *dso_list_str, *comm_list_str, *sym_list_str,
39static struct strlist *dso_list, *comm_list, *sym_list; 39static struct strlist *dso_list, *comm_list, *sym_list;
40 40
41static int force; 41static int force;
42static bool use_modules;
43 42
44static int full_paths; 43static int full_paths;
45static int show_nr_samples; 44static int show_nr_samples;
@@ -53,12 +52,13 @@ static char *pretty_printing_style = default_pretty_printing_style;
53static int exclude_other = 1; 52static int exclude_other = 1;
54 53
55static char callchain_default_opt[] = "fractal,0.5"; 54static char callchain_default_opt[] = "fractal,0.5";
56const char *vmlinux_name;
57 55
58static struct perf_header *header; 56static struct perf_header *header;
59 57
60static u64 sample_type; 58static u64 sample_type;
61 59
60struct symbol_conf symbol_conf;
61
62 62
63static size_t 63static size_t
64callchain__fprintf_left_margin(FILE *fp, int left_margin) 64callchain__fprintf_left_margin(FILE *fp, int left_margin)
@@ -865,8 +865,7 @@ static int __cmd_report(void)
865 865
866 register_perf_file_handler(&file_handler); 866 register_perf_file_handler(&file_handler);
867 867
868 ret = mmap_dispatch_perf_file(&header, input_name, vmlinux_name, 868 ret = mmap_dispatch_perf_file(&header, input_name, force,
869 !vmlinux_name, force,
870 full_paths, &cwdlen, &cwd); 869 full_paths, &cwdlen, &cwd);
871 if (ret) 870 if (ret)
872 return ret; 871 return ret;
@@ -963,9 +962,10 @@ static const struct option options[] = {
963 "be more verbose (show symbol address, etc)"), 962 "be more verbose (show symbol address, etc)"),
964 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 963 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
965 "dump raw trace in ASCII"), 964 "dump raw trace in ASCII"),
966 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), 965 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
966 "file", "vmlinux pathname"),
967 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), 967 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
968 OPT_BOOLEAN('m', "modules", &use_modules, 968 OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
969 "load module symbols - WARNING: use only with -k and LIVE kernel"), 969 "load module symbols - WARNING: use only with -k and LIVE kernel"),
970 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples, 970 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples,
971 "Show a column with the number of samples"), 971 "Show a column with the number of samples"),
@@ -1035,7 +1035,8 @@ static void setup_list(struct strlist **list, const char *list_str,
1035 1035
1036int cmd_report(int argc, const char **argv, const char *prefix __used) 1036int cmd_report(int argc, const char **argv, const char *prefix __used)
1037{ 1037{
1038 symbol__init(0); 1038 if (symbol__init(&symbol_conf) < 0)
1039 return -1;
1039 1040
1040 argc = parse_options(argc, argv, options, report_usage, 0); 1041 argc = parse_options(argc, argv, options, report_usage, 0);
1041 1042
diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
index 260f57a72ee0..dbf089b12def 100644
--- a/tools/perf/builtin-sched.c
+++ b/tools/perf/builtin-sched.c
@@ -1718,7 +1718,7 @@ static int read_events(void)
1718 register_idle_thread(); 1718 register_idle_thread();
1719 register_perf_file_handler(&file_handler); 1719 register_perf_file_handler(&file_handler);
1720 1720
1721 return mmap_dispatch_perf_file(&header, input_name, NULL, false, 0, 0, 1721 return mmap_dispatch_perf_file(&header, input_name, 0, 0,
1722 &cwdlen, &cwd); 1722 &cwdlen, &cwd);
1723} 1723}
1724 1724
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index b9a321fd184e..a21247543fc1 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -79,7 +79,7 @@ static int dump_symtab = 0;
79static bool hide_kernel_symbols = false; 79static bool hide_kernel_symbols = false;
80static bool hide_user_symbols = false; 80static bool hide_user_symbols = false;
81static struct winsize winsize; 81static struct winsize winsize;
82const char *vmlinux_name; 82struct symbol_conf symbol_conf;
83 83
84/* 84/*
85 * Source 85 * Source
@@ -128,7 +128,7 @@ struct sym_entry {
128 128
129static inline struct symbol *sym_entry__symbol(struct sym_entry *self) 129static inline struct symbol *sym_entry__symbol(struct sym_entry *self)
130{ 130{
131 return ((void *)self) + symbol__priv_size; 131 return ((void *)self) + symbol_conf.priv_size;
132} 132}
133 133
134static void get_term_dimensions(struct winsize *ws) 134static void get_term_dimensions(struct winsize *ws)
@@ -695,7 +695,7 @@ static void print_mapped_keys(void)
695 695
696 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter); 696 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter);
697 697
698 if (vmlinux_name) { 698 if (symbol_conf.vmlinux_name) {
699 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter); 699 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter);
700 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL"); 700 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL");
701 fprintf(stdout, "\t[S] stop annotation.\n"); 701 fprintf(stdout, "\t[S] stop annotation.\n");
@@ -732,7 +732,7 @@ static int key_mapped(int c)
732 case 'F': 732 case 'F':
733 case 's': 733 case 's':
734 case 'S': 734 case 'S':
735 return vmlinux_name ? 1 : 0; 735 return symbol_conf.vmlinux_name ? 1 : 0;
736 default: 736 default:
737 break; 737 break;
738 } 738 }
@@ -1261,7 +1261,8 @@ static const struct option options[] = {
1261 "system-wide collection from all CPUs"), 1261 "system-wide collection from all CPUs"),
1262 OPT_INTEGER('C', "CPU", &profile_cpu, 1262 OPT_INTEGER('C', "CPU", &profile_cpu,
1263 "CPU to profile on"), 1263 "CPU to profile on"),
1264 OPT_STRING('k', "vmlinux", &vmlinux_name, "file", "vmlinux pathname"), 1264 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
1265 "file", "vmlinux pathname"),
1265 OPT_BOOLEAN('K', "hide_kernel_symbols", &hide_kernel_symbols, 1266 OPT_BOOLEAN('K', "hide_kernel_symbols", &hide_kernel_symbols,
1266 "hide kernel symbols"), 1267 "hide kernel symbols"),
1267 OPT_INTEGER('m', "mmap-pages", &mmap_pages, 1268 OPT_INTEGER('m', "mmap-pages", &mmap_pages,
@@ -1295,7 +1296,7 @@ static const struct option options[] = {
1295 1296
1296int cmd_top(int argc, const char **argv, const char *prefix __used) 1297int cmd_top(int argc, const char **argv, const char *prefix __used)
1297{ 1298{
1298 int counter, err; 1299 int counter;
1299 1300
1300 page_size = sysconf(_SC_PAGE_SIZE); 1301 page_size = sysconf(_SC_PAGE_SIZE);
1301 1302
@@ -1313,15 +1314,16 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
1313 if (!nr_counters) 1314 if (!nr_counters)
1314 nr_counters = 1; 1315 nr_counters = 1;
1315 1316
1316 symbol__init(sizeof(struct sym_entry) + 1317 symbol_conf.priv_size = (sizeof(struct sym_entry) +
1317 (nr_counters + 1) * sizeof(unsigned long)); 1318 (nr_counters + 1) * sizeof(unsigned long));
1319 if (symbol_conf.vmlinux_name == NULL)
1320 symbol_conf.try_vmlinux_path = true;
1321 if (symbol__init(&symbol_conf) < 0)
1322 return -1;
1318 1323
1319 if (delay_secs < 1) 1324 if (delay_secs < 1)
1320 delay_secs = 1; 1325 delay_secs = 1;
1321 1326
1322 err = kernel_maps__init(vmlinux_name, !vmlinux_name, true);
1323 if (err < 0)
1324 return err;
1325 parse_source(sym_filter_entry); 1327 parse_source(sym_filter_entry);
1326 1328
1327 /* 1329 /*
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index b71198e5dc14..75972fd073df 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -131,7 +131,7 @@ static int __cmd_trace(void)
131 register_idle_thread(); 131 register_idle_thread();
132 register_perf_file_handler(&file_handler); 132 register_perf_file_handler(&file_handler);
133 133
134 return mmap_dispatch_perf_file(&header, input_name, NULL, false, 134 return mmap_dispatch_perf_file(&header, input_name,
135 0, 0, &cwdlen, &cwd); 135 0, 0, &cwdlen, &cwd);
136} 136}
137 137
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c
index f318d19b2562..b238462b8983 100644
--- a/tools/perf/util/data_map.c
+++ b/tools/perf/util/data_map.c
@@ -101,8 +101,6 @@ out:
101 101
102int mmap_dispatch_perf_file(struct perf_header **pheader, 102int mmap_dispatch_perf_file(struct perf_header **pheader,
103 const char *input_name, 103 const char *input_name,
104 const char *vmlinux_name,
105 bool try_vmlinux_path,
106 int force, 104 int force,
107 int full_paths, 105 int full_paths,
108 int *cwdlen, 106 int *cwdlen,
@@ -172,12 +170,6 @@ int mmap_dispatch_perf_file(struct perf_header **pheader,
172 curr_handler->sample_type_check(sample_type) < 0) 170 curr_handler->sample_type_check(sample_type) < 0)
173 goto out_delete; 171 goto out_delete;
174 172
175 err = -ENOMEM;
176 if (kernel_maps__init(vmlinux_name, try_vmlinux_path, true) < 0) {
177 pr_err("failed to setup the kernel maps to resolve symbols\n");
178 goto out_delete;
179 }
180
181 if (!full_paths) { 173 if (!full_paths) {
182 if (getcwd(__cwd, sizeof(__cwd)) == NULL) { 174 if (getcwd(__cwd, sizeof(__cwd)) == NULL) {
183 pr_err("failed to get the current directory\n"); 175 pr_err("failed to get the current directory\n");
diff --git a/tools/perf/util/data_map.h b/tools/perf/util/data_map.h
index 3f0d21b3819e..ae036ecd7625 100644
--- a/tools/perf/util/data_map.h
+++ b/tools/perf/util/data_map.h
@@ -23,8 +23,6 @@ struct perf_file_handler {
23void register_perf_file_handler(struct perf_file_handler *handler); 23void register_perf_file_handler(struct perf_file_handler *handler);
24int mmap_dispatch_perf_file(struct perf_header **pheader, 24int mmap_dispatch_perf_file(struct perf_header **pheader,
25 const char *input_name, 25 const char *input_name,
26 const char *vmlinux_name,
27 bool try_vmlinux_path,
28 int force, 26 int force,
29 int full_paths, 27 int full_paths,
30 int *cwdlen, 28 int *cwdlen,
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 1332f8ec04aa..271a1600e6f7 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -253,12 +253,6 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
253 253
254 buildid_sec = &feat_sec[idx++]; 254 buildid_sec = &feat_sec[idx++];
255 255
256 /*
257 * Read the kernel buildid nad the list of loaded modules with
258 * its build_ids:
259 */
260 kernel_maps__init(NULL, false, true);
261
262 /* Write build-ids */ 256 /* Write build-ids */
263 buildid_sec->offset = lseek(fd, 0, SEEK_CUR); 257 buildid_sec->offset = lseek(fd, 0, SEEK_CUR);
264 err = dsos__write_buildid_table(fd); 258 err = dsos__write_buildid_table(fd);
diff --git a/tools/perf/util/include/asm/bug.h b/tools/perf/util/include/asm/bug.h
new file mode 100644
index 000000000000..7fcc6810adc2
--- /dev/null
+++ b/tools/perf/util/include/asm/bug.h
@@ -0,0 +1,22 @@
1#ifndef _PERF_ASM_GENERIC_BUG_H
2#define _PERF_ASM_GENERIC_BUG_H
3
4#define __WARN_printf(arg...) do { fprintf(stderr, arg); } while (0)
5
6#define WARN(condition, format...) ({ \
7 int __ret_warn_on = !!(condition); \
8 if (unlikely(__ret_warn_on)) \
9 __WARN_printf(format); \
10 unlikely(__ret_warn_on); \
11})
12
13#define WARN_ONCE(condition, format...) ({ \
14 static int __warned; \
15 int __ret_warn_once = !!(condition); \
16 \
17 if (unlikely(__ret_warn_once)) \
18 if (WARN(!__warned, format)) \
19 __warned = 1; \
20 unlikely(__ret_warn_once); \
21})
22#endif
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 44d81d5ae8cf..c4ca974b36e3 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -6,6 +6,7 @@
6 6
7#include "debug.h" 7#include "debug.h"
8 8
9#include <asm/bug.h>
9#include <libelf.h> 10#include <libelf.h>
10#include <gelf.h> 11#include <gelf.h>
11#include <elf.h> 12#include <elf.h>
@@ -37,6 +38,11 @@ unsigned int symbol__priv_size;
37static int vmlinux_path__nr_entries; 38static int vmlinux_path__nr_entries;
38static char **vmlinux_path; 39static char **vmlinux_path;
39 40
41static struct symbol_conf symbol_conf__defaults = {
42 .use_modules = true,
43 .try_vmlinux_path = true,
44};
45
40static struct rb_root kernel_maps; 46static struct rb_root kernel_maps;
41 47
42static void dso__fixup_sym_end(struct dso *self) 48static void dso__fixup_sym_end(struct dso *self)
@@ -1166,7 +1172,9 @@ struct symbol *kernel_maps__find_symbol(u64 ip, struct map **mapp,
1166 if (map) { 1172 if (map) {
1167 ip = map->map_ip(map, ip); 1173 ip = map->map_ip(map, ip);
1168 return map__find_symbol(map, ip, filter); 1174 return map__find_symbol(map, ip, filter);
1169 } 1175 } else
1176 WARN_ONCE(RB_EMPTY_ROOT(&kernel_maps),
1177 "Empty kernel_maps, was symbol__init() called?\n");
1170 1178
1171 return NULL; 1179 return NULL;
1172} 1180}
@@ -1485,9 +1493,9 @@ size_t dsos__fprintf_buildid(FILE *fp)
1485 return ret; 1493 return ret;
1486} 1494}
1487 1495
1488static int kernel_maps__create_kernel_map(const char *vmlinux_name) 1496static int kernel_maps__create_kernel_map(const struct symbol_conf *conf)
1489{ 1497{
1490 struct dso *kernel = dso__new(vmlinux_name ?: "[kernel.kallsyms]"); 1498 struct dso *kernel = dso__new(conf->vmlinux_name ?: "[kernel.kallsyms]");
1491 1499
1492 if (kernel == NULL) 1500 if (kernel == NULL)
1493 return -1; 1501 return -1;
@@ -1577,18 +1585,21 @@ out_fail:
1577 return -1; 1585 return -1;
1578} 1586}
1579 1587
1580int kernel_maps__init(const char *vmlinux_name, bool try_vmlinux_path, 1588static int kernel_maps__init(const struct symbol_conf *conf)
1581 bool use_modules)
1582{ 1589{
1583 if (try_vmlinux_path && vmlinux_path__init() < 0) 1590 const struct symbol_conf *pconf = conf ?: &symbol_conf__defaults;
1591
1592 symbol__priv_size = pconf->priv_size;
1593
1594 if (pconf->try_vmlinux_path && vmlinux_path__init() < 0)
1584 return -1; 1595 return -1;
1585 1596
1586 if (kernel_maps__create_kernel_map(vmlinux_name) < 0) { 1597 if (kernel_maps__create_kernel_map(pconf) < 0) {
1587 vmlinux_path__exit(); 1598 vmlinux_path__exit();
1588 return -1; 1599 return -1;
1589 } 1600 }
1590 1601
1591 if (use_modules && kernel_maps__create_module_maps() < 0) 1602 if (pconf->use_modules && kernel_maps__create_module_maps() < 0)
1592 pr_debug("Failed to load list of modules in use, " 1603 pr_debug("Failed to load list of modules in use, "
1593 "continuing...\n"); 1604 "continuing...\n");
1594 /* 1605 /*
@@ -1598,8 +1609,8 @@ int kernel_maps__init(const char *vmlinux_name, bool try_vmlinux_path,
1598 return 0; 1609 return 0;
1599} 1610}
1600 1611
1601void symbol__init(unsigned int priv_size) 1612int symbol__init(struct symbol_conf *conf)
1602{ 1613{
1603 elf_version(EV_CURRENT); 1614 elf_version(EV_CURRENT);
1604 symbol__priv_size = priv_size; 1615 return kernel_maps__init(conf);
1605} 1616}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 8c4d026e067a..5538691494af 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -49,6 +49,13 @@ struct symbol {
49 char name[0]; 49 char name[0];
50}; 50};
51 51
52struct symbol_conf {
53 unsigned short priv_size;
54 bool try_vmlinux_path,
55 use_modules;
56 const char *vmlinux_name;
57};
58
52extern unsigned int symbol__priv_size; 59extern unsigned int symbol__priv_size;
53 60
54static inline void *symbol__priv(struct symbol *self) 61static inline void *symbol__priv(struct symbol *self)
@@ -93,11 +100,9 @@ int sysfs__read_build_id(const char *filename, void *bf, size_t size);
93bool dsos__read_build_ids(void); 100bool dsos__read_build_ids(void);
94int build_id__sprintf(u8 *self, int len, char *bf); 101int build_id__sprintf(u8 *self, int len, char *bf);
95 102
96int kernel_maps__init(const char *vmlinux_name, bool try_vmlinux_path,
97 bool use_modules);
98size_t kernel_maps__fprintf(FILE *fp); 103size_t kernel_maps__fprintf(FILE *fp);
99 104
100void symbol__init(unsigned int priv_size); 105int symbol__init(struct symbol_conf *conf);
101 106
102extern struct list_head dsos; 107extern struct list_head dsos;
103extern struct map *kernel_map; 108extern struct map *kernel_map;