diff options
author | David S. Miller <davem@davemloft.net> | 2010-12-27 01:37:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-27 01:37:05 -0500 |
commit | 17f7f4d9fcce8f1b75b5f735569309dee7665968 (patch) | |
tree | 14d7e49ca0053a0fcab3c33b5023bf3f90c5c08a /tools | |
parent | 041110a439e21cd40709ead4ffbfa8034619ad77 (diff) | |
parent | d7c1255a3a21e98bdc64df8ccf005a174d7e6289 (diff) |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
Conflicts:
net/ipv4/fib_frontend.c
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-buildid-list.c | 3 | ||||
-rw-r--r-- | tools/perf/builtin-probe.c | 5 | ||||
-rw-r--r-- | tools/perf/builtin-record.c | 23 | ||||
-rw-r--r-- | tools/perf/util/header.c | 21 | ||||
-rw-r--r-- | tools/perf/util/probe-event.c | 15 | ||||
-rw-r--r-- | tools/perf/util/probe-finder.c | 85 | ||||
-rw-r--r-- | tools/perf/util/string.c | 2 | ||||
-rw-r--r-- | tools/perf/util/symbol.c | 67 | ||||
-rw-r--r-- | tools/perf/util/symbol.h | 2 |
9 files changed, 161 insertions, 62 deletions
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c index 44a47e13bd67..c49837de7d3f 100644 --- a/tools/perf/builtin-buildid-list.c +++ b/tools/perf/builtin-buildid-list.c | |||
@@ -36,7 +36,6 @@ static const struct option options[] = { | |||
36 | 36 | ||
37 | static int __cmd_buildid_list(void) | 37 | static int __cmd_buildid_list(void) |
38 | { | 38 | { |
39 | int err = -1; | ||
40 | struct perf_session *session; | 39 | struct perf_session *session; |
41 | 40 | ||
42 | session = perf_session__new(input_name, O_RDONLY, force, false); | 41 | session = perf_session__new(input_name, O_RDONLY, force, false); |
@@ -49,7 +48,7 @@ static int __cmd_buildid_list(void) | |||
49 | perf_session__fprintf_dsos_buildid(session, stdout, with_hits); | 48 | perf_session__fprintf_dsos_buildid(session, stdout, with_hits); |
50 | 49 | ||
51 | perf_session__delete(session); | 50 | perf_session__delete(session); |
52 | return err; | 51 | return 0; |
53 | } | 52 | } |
54 | 53 | ||
55 | int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) | 54 | int cmd_buildid_list(int argc, const char **argv, const char *prefix __used) |
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 2e000c068cc5..add163c9f0e7 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c | |||
@@ -249,6 +249,11 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used) | |||
249 | !params.show_lines)) | 249 | !params.show_lines)) |
250 | usage_with_options(probe_usage, options); | 250 | usage_with_options(probe_usage, options); |
251 | 251 | ||
252 | /* | ||
253 | * Only consider the user's kernel image path if given. | ||
254 | */ | ||
255 | symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL); | ||
256 | |||
252 | if (params.list_events) { | 257 | if (params.list_events) { |
253 | if (params.mod_events) { | 258 | if (params.mod_events) { |
254 | pr_err(" Error: Don't use --list with --add/--del.\n"); | 259 | pr_err(" Error: Don't use --list with --add/--del.\n"); |
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 93bd2ff001fb..564491fa18b2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -197,7 +197,7 @@ static void sig_atexit(void) | |||
197 | if (child_pid > 0) | 197 | if (child_pid > 0) |
198 | kill(child_pid, SIGTERM); | 198 | kill(child_pid, SIGTERM); |
199 | 199 | ||
200 | if (signr == -1) | 200 | if (signr == -1 || signr == SIGUSR1) |
201 | return; | 201 | return; |
202 | 202 | ||
203 | signal(signr, SIG_DFL); | 203 | signal(signr, SIG_DFL); |
@@ -515,6 +515,7 @@ static int __cmd_record(int argc, const char **argv) | |||
515 | atexit(sig_atexit); | 515 | atexit(sig_atexit); |
516 | signal(SIGCHLD, sig_handler); | 516 | signal(SIGCHLD, sig_handler); |
517 | signal(SIGINT, sig_handler); | 517 | signal(SIGINT, sig_handler); |
518 | signal(SIGUSR1, sig_handler); | ||
518 | 519 | ||
519 | if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { | 520 | if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { |
520 | perror("failed to create pipes"); | 521 | perror("failed to create pipes"); |
@@ -606,6 +607,7 @@ static int __cmd_record(int argc, const char **argv) | |||
606 | execvp(argv[0], (char **)argv); | 607 | execvp(argv[0], (char **)argv); |
607 | 608 | ||
608 | perror(argv[0]); | 609 | perror(argv[0]); |
610 | kill(getppid(), SIGUSR1); | ||
609 | exit(-1); | 611 | exit(-1); |
610 | } | 612 | } |
611 | 613 | ||
@@ -697,17 +699,18 @@ static int __cmd_record(int argc, const char **argv) | |||
697 | if (err < 0) | 699 | if (err < 0) |
698 | err = event__synthesize_kernel_mmap(process_synthesized_event, | 700 | err = event__synthesize_kernel_mmap(process_synthesized_event, |
699 | session, machine, "_stext"); | 701 | session, machine, "_stext"); |
700 | if (err < 0) { | 702 | if (err < 0) |
701 | pr_err("Couldn't record kernel reference relocation symbol.\n"); | 703 | pr_err("Couldn't record kernel reference relocation symbol\n" |
702 | return err; | 704 | "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" |
703 | } | 705 | "Check /proc/kallsyms permission or run as root.\n"); |
704 | 706 | ||
705 | err = event__synthesize_modules(process_synthesized_event, | 707 | err = event__synthesize_modules(process_synthesized_event, |
706 | session, machine); | 708 | session, machine); |
707 | if (err < 0) { | 709 | if (err < 0) |
708 | pr_err("Couldn't record kernel reference relocation symbol.\n"); | 710 | pr_err("Couldn't record kernel module information.\n" |
709 | return err; | 711 | "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" |
710 | } | 712 | "Check /proc/modules permission or run as root.\n"); |
713 | |||
711 | if (perf_guest) | 714 | if (perf_guest) |
712 | perf_session__process_machines(session, event__synthesize_guest_os); | 715 | perf_session__process_machines(session, event__synthesize_guest_os); |
713 | 716 | ||
@@ -761,7 +764,7 @@ static int __cmd_record(int argc, const char **argv) | |||
761 | } | 764 | } |
762 | } | 765 | } |
763 | 766 | ||
764 | if (quiet) | 767 | if (quiet || signr == SIGUSR1) |
765 | return 0; | 768 | return 0; |
766 | 769 | ||
767 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); | 770 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index d7e67b167ea3..7cba0551a565 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -265,15 +265,16 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
265 | const char *name, bool is_kallsyms) | 265 | const char *name, bool is_kallsyms) |
266 | { | 266 | { |
267 | const size_t size = PATH_MAX; | 267 | const size_t size = PATH_MAX; |
268 | char *filename = malloc(size), | 268 | char *realname = realpath(name, NULL), |
269 | *filename = malloc(size), | ||
269 | *linkname = malloc(size), *targetname; | 270 | *linkname = malloc(size), *targetname; |
270 | int len, err = -1; | 271 | int len, err = -1; |
271 | 272 | ||
272 | if (filename == NULL || linkname == NULL) | 273 | if (realname == NULL || filename == NULL || linkname == NULL) |
273 | goto out_free; | 274 | goto out_free; |
274 | 275 | ||
275 | len = snprintf(filename, size, "%s%s%s", | 276 | len = snprintf(filename, size, "%s%s%s", |
276 | debugdir, is_kallsyms ? "/" : "", name); | 277 | debugdir, is_kallsyms ? "/" : "", realname); |
277 | if (mkdir_p(filename, 0755)) | 278 | if (mkdir_p(filename, 0755)) |
278 | goto out_free; | 279 | goto out_free; |
279 | 280 | ||
@@ -283,7 +284,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
283 | if (is_kallsyms) { | 284 | if (is_kallsyms) { |
284 | if (copyfile("/proc/kallsyms", filename)) | 285 | if (copyfile("/proc/kallsyms", filename)) |
285 | goto out_free; | 286 | goto out_free; |
286 | } else if (link(name, filename) && copyfile(name, filename)) | 287 | } else if (link(realname, filename) && copyfile(name, filename)) |
287 | goto out_free; | 288 | goto out_free; |
288 | } | 289 | } |
289 | 290 | ||
@@ -300,6 +301,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir, | |||
300 | if (symlink(targetname, linkname) == 0) | 301 | if (symlink(targetname, linkname) == 0) |
301 | err = 0; | 302 | err = 0; |
302 | out_free: | 303 | out_free: |
304 | free(realname); | ||
303 | free(filename); | 305 | free(filename); |
304 | free(linkname); | 306 | free(linkname); |
305 | return err; | 307 | return err; |
@@ -946,11 +948,16 @@ perf_header__find_attr(u64 id, struct perf_header *header) | |||
946 | 948 | ||
947 | /* | 949 | /* |
948 | * We set id to -1 if the data file doesn't contain sample | 950 | * We set id to -1 if the data file doesn't contain sample |
949 | * ids. Check for this and avoid walking through the entire | 951 | * ids. This can happen when the data file contains one type |
950 | * list of ids which may be large. | 952 | * of event and in that case, the header can still store the |
953 | * event attribute information. Check for this and avoid | ||
954 | * walking through the entire list of ids which may be large. | ||
951 | */ | 955 | */ |
952 | if (id == -1ULL) | 956 | if (id == -1ULL) { |
957 | if (header->attrs > 0) | ||
958 | return &header->attr[0]->attr; | ||
953 | return NULL; | 959 | return NULL; |
960 | } | ||
954 | 961 | ||
955 | for (i = 0; i < header->attrs; i++) { | 962 | for (i = 0; i < header->attrs; i++) { |
956 | struct perf_header_attr *attr = header->attr[i]; | 963 | struct perf_header_attr *attr = header->attr[i]; |
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index 3b6a5297bf16..61191c6cbe7a 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c | |||
@@ -114,6 +114,8 @@ static struct symbol *__find_kernel_function_by_name(const char *name, | |||
114 | const char *kernel_get_module_path(const char *module) | 114 | const char *kernel_get_module_path(const char *module) |
115 | { | 115 | { |
116 | struct dso *dso; | 116 | struct dso *dso; |
117 | struct map *map; | ||
118 | const char *vmlinux_name; | ||
117 | 119 | ||
118 | if (module) { | 120 | if (module) { |
119 | list_for_each_entry(dso, &machine.kernel_dsos, node) { | 121 | list_for_each_entry(dso, &machine.kernel_dsos, node) { |
@@ -123,10 +125,17 @@ const char *kernel_get_module_path(const char *module) | |||
123 | } | 125 | } |
124 | pr_debug("Failed to find module %s.\n", module); | 126 | pr_debug("Failed to find module %s.\n", module); |
125 | return NULL; | 127 | return NULL; |
128 | } | ||
129 | |||
130 | map = machine.vmlinux_maps[MAP__FUNCTION]; | ||
131 | dso = map->dso; | ||
132 | |||
133 | vmlinux_name = symbol_conf.vmlinux_name; | ||
134 | if (vmlinux_name) { | ||
135 | if (dso__load_vmlinux(dso, map, vmlinux_name, NULL) <= 0) | ||
136 | return NULL; | ||
126 | } else { | 137 | } else { |
127 | dso = machine.vmlinux_maps[MAP__FUNCTION]->dso; | 138 | if (dso__load_vmlinux_path(dso, map, NULL) <= 0) { |
128 | if (dso__load_vmlinux_path(dso, | ||
129 | machine.vmlinux_maps[MAP__FUNCTION], NULL) < 0) { | ||
130 | pr_debug("Failed to load kernel map.\n"); | 139 | pr_debug("Failed to load kernel map.\n"); |
131 | return NULL; | 140 | return NULL; |
132 | } | 141 | } |
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c index 3991d73d1cff..ddf4d4556321 100644 --- a/tools/perf/util/probe-finder.c +++ b/tools/perf/util/probe-finder.c | |||
@@ -117,28 +117,6 @@ static void line_list__free(struct list_head *head) | |||
117 | } | 117 | } |
118 | 118 | ||
119 | /* Dwarf FL wrappers */ | 119 | /* Dwarf FL wrappers */ |
120 | |||
121 | static int __linux_kernel_find_elf(Dwfl_Module *mod, | ||
122 | void **userdata, | ||
123 | const char *module_name, | ||
124 | Dwarf_Addr base, | ||
125 | char **file_name, Elf **elfp) | ||
126 | { | ||
127 | int fd; | ||
128 | const char *path = kernel_get_module_path(module_name); | ||
129 | |||
130 | if (path) { | ||
131 | fd = open(path, O_RDONLY); | ||
132 | if (fd >= 0) { | ||
133 | *file_name = strdup(path); | ||
134 | return fd; | ||
135 | } | ||
136 | } | ||
137 | /* If failed, try to call standard method */ | ||
138 | return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base, | ||
139 | file_name, elfp); | ||
140 | } | ||
141 | |||
142 | static char *debuginfo_path; /* Currently dummy */ | 120 | static char *debuginfo_path; /* Currently dummy */ |
143 | 121 | ||
144 | static const Dwfl_Callbacks offline_callbacks = { | 122 | static const Dwfl_Callbacks offline_callbacks = { |
@@ -151,14 +129,6 @@ static const Dwfl_Callbacks offline_callbacks = { | |||
151 | .find_elf = dwfl_build_id_find_elf, | 129 | .find_elf = dwfl_build_id_find_elf, |
152 | }; | 130 | }; |
153 | 131 | ||
154 | static const Dwfl_Callbacks kernel_callbacks = { | ||
155 | .find_debuginfo = dwfl_standard_find_debuginfo, | ||
156 | .debuginfo_path = &debuginfo_path, | ||
157 | |||
158 | .find_elf = __linux_kernel_find_elf, | ||
159 | .section_address = dwfl_linux_kernel_module_section_address, | ||
160 | }; | ||
161 | |||
162 | /* Get a Dwarf from offline image */ | 132 | /* Get a Dwarf from offline image */ |
163 | static Dwarf *dwfl_init_offline_dwarf(int fd, Dwfl **dwflp, Dwarf_Addr *bias) | 133 | static Dwarf *dwfl_init_offline_dwarf(int fd, Dwfl **dwflp, Dwarf_Addr *bias) |
164 | { | 134 | { |
@@ -185,6 +155,38 @@ error: | |||
185 | return dbg; | 155 | return dbg; |
186 | } | 156 | } |
187 | 157 | ||
158 | #if _ELFUTILS_PREREQ(0, 148) | ||
159 | /* This method is buggy if elfutils is older than 0.148 */ | ||
160 | static int __linux_kernel_find_elf(Dwfl_Module *mod, | ||
161 | void **userdata, | ||
162 | const char *module_name, | ||
163 | Dwarf_Addr base, | ||
164 | char **file_name, Elf **elfp) | ||
165 | { | ||
166 | int fd; | ||
167 | const char *path = kernel_get_module_path(module_name); | ||
168 | |||
169 | pr_debug2("Use file %s for %s\n", path, module_name); | ||
170 | if (path) { | ||
171 | fd = open(path, O_RDONLY); | ||
172 | if (fd >= 0) { | ||
173 | *file_name = strdup(path); | ||
174 | return fd; | ||
175 | } | ||
176 | } | ||
177 | /* If failed, try to call standard method */ | ||
178 | return dwfl_linux_kernel_find_elf(mod, userdata, module_name, base, | ||
179 | file_name, elfp); | ||
180 | } | ||
181 | |||
182 | static const Dwfl_Callbacks kernel_callbacks = { | ||
183 | .find_debuginfo = dwfl_standard_find_debuginfo, | ||
184 | .debuginfo_path = &debuginfo_path, | ||
185 | |||
186 | .find_elf = __linux_kernel_find_elf, | ||
187 | .section_address = dwfl_linux_kernel_module_section_address, | ||
188 | }; | ||
189 | |||
188 | /* Get a Dwarf from live kernel image */ | 190 | /* Get a Dwarf from live kernel image */ |
189 | static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, | 191 | static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, |
190 | Dwarf_Addr *bias) | 192 | Dwarf_Addr *bias) |
@@ -205,11 +207,34 @@ static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr, Dwfl **dwflp, | |||
205 | dbg = dwfl_addrdwarf(*dwflp, addr, bias); | 207 | dbg = dwfl_addrdwarf(*dwflp, addr, bias); |
206 | /* Here, check whether we could get a real dwarf */ | 208 | /* Here, check whether we could get a real dwarf */ |
207 | if (!dbg) { | 209 | if (!dbg) { |
210 | pr_debug("Failed to find kernel dwarf at %lx\n", | ||
211 | (unsigned long)addr); | ||
208 | dwfl_end(*dwflp); | 212 | dwfl_end(*dwflp); |
209 | *dwflp = NULL; | 213 | *dwflp = NULL; |
210 | } | 214 | } |
211 | return dbg; | 215 | return dbg; |
212 | } | 216 | } |
217 | #else | ||
218 | /* With older elfutils, this just support kernel module... */ | ||
219 | static Dwarf *dwfl_init_live_kernel_dwarf(Dwarf_Addr addr __used, Dwfl **dwflp, | ||
220 | Dwarf_Addr *bias) | ||
221 | { | ||
222 | int fd; | ||
223 | const char *path = kernel_get_module_path("kernel"); | ||
224 | |||
225 | if (!path) { | ||
226 | pr_err("Failed to find vmlinux path\n"); | ||
227 | return NULL; | ||
228 | } | ||
229 | |||
230 | pr_debug2("Use file %s for debuginfo\n", path); | ||
231 | fd = open(path, O_RDONLY); | ||
232 | if (fd < 0) | ||
233 | return NULL; | ||
234 | |||
235 | return dwfl_init_offline_dwarf(fd, dwflp, bias); | ||
236 | } | ||
237 | #endif | ||
213 | 238 | ||
214 | /* Dwarf wrappers */ | 239 | /* Dwarf wrappers */ |
215 | 240 | ||
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c index 0409fc7c0058..8fc0bd3a3a4a 100644 --- a/tools/perf/util/string.c +++ b/tools/perf/util/string.c | |||
@@ -259,7 +259,7 @@ static bool __match_glob(const char *str, const char *pat, bool ignore_space) | |||
259 | if (!*pat) /* Tail wild card matches all */ | 259 | if (!*pat) /* Tail wild card matches all */ |
260 | return true; | 260 | return true; |
261 | while (*str) | 261 | while (*str) |
262 | if (strglobmatch(str++, pat)) | 262 | if (__match_glob(str++, pat, ignore_space)) |
263 | return true; | 263 | return true; |
264 | } | 264 | } |
265 | return !*str && !*pat; | 265 | return !*str && !*pat; |
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index b39f499e575a..439ab947daf4 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c | |||
@@ -295,7 +295,9 @@ static void symbols__insert_by_name(struct rb_root *self, struct symbol *sym) | |||
295 | { | 295 | { |
296 | struct rb_node **p = &self->rb_node; | 296 | struct rb_node **p = &self->rb_node; |
297 | struct rb_node *parent = NULL; | 297 | struct rb_node *parent = NULL; |
298 | struct symbol_name_rb_node *symn = ((void *)sym) - sizeof(*parent), *s; | 298 | struct symbol_name_rb_node *symn, *s; |
299 | |||
300 | symn = container_of(sym, struct symbol_name_rb_node, sym); | ||
299 | 301 | ||
300 | while (*p != NULL) { | 302 | while (*p != NULL) { |
301 | parent = *p; | 303 | parent = *p; |
@@ -530,7 +532,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
530 | struct machine *machine = kmaps->machine; | 532 | struct machine *machine = kmaps->machine; |
531 | struct map *curr_map = map; | 533 | struct map *curr_map = map; |
532 | struct symbol *pos; | 534 | struct symbol *pos; |
533 | int count = 0; | 535 | int count = 0, moved = 0; |
534 | struct rb_root *root = &self->symbols[map->type]; | 536 | struct rb_root *root = &self->symbols[map->type]; |
535 | struct rb_node *next = rb_first(root); | 537 | struct rb_node *next = rb_first(root); |
536 | int kernel_range = 0; | 538 | int kernel_range = 0; |
@@ -588,6 +590,11 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
588 | char dso_name[PATH_MAX]; | 590 | char dso_name[PATH_MAX]; |
589 | struct dso *dso; | 591 | struct dso *dso; |
590 | 592 | ||
593 | if (count == 0) { | ||
594 | curr_map = map; | ||
595 | goto filter_symbol; | ||
596 | } | ||
597 | |||
591 | if (self->kernel == DSO_TYPE_GUEST_KERNEL) | 598 | if (self->kernel == DSO_TYPE_GUEST_KERNEL) |
592 | snprintf(dso_name, sizeof(dso_name), | 599 | snprintf(dso_name, sizeof(dso_name), |
593 | "[guest.kernel].%d", | 600 | "[guest.kernel].%d", |
@@ -613,7 +620,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map, | |||
613 | map_groups__insert(kmaps, curr_map); | 620 | map_groups__insert(kmaps, curr_map); |
614 | ++kernel_range; | 621 | ++kernel_range; |
615 | } | 622 | } |
616 | 623 | filter_symbol: | |
617 | if (filter && filter(curr_map, pos)) { | 624 | if (filter && filter(curr_map, pos)) { |
618 | discard_symbol: rb_erase(&pos->rb_node, root); | 625 | discard_symbol: rb_erase(&pos->rb_node, root); |
619 | symbol__delete(pos); | 626 | symbol__delete(pos); |
@@ -621,8 +628,9 @@ discard_symbol: rb_erase(&pos->rb_node, root); | |||
621 | if (curr_map != map) { | 628 | if (curr_map != map) { |
622 | rb_erase(&pos->rb_node, root); | 629 | rb_erase(&pos->rb_node, root); |
623 | symbols__insert(&curr_map->dso->symbols[curr_map->type], pos); | 630 | symbols__insert(&curr_map->dso->symbols[curr_map->type], pos); |
624 | } | 631 | ++moved; |
625 | count++; | 632 | } else |
633 | ++count; | ||
626 | } | 634 | } |
627 | } | 635 | } |
628 | 636 | ||
@@ -632,7 +640,7 @@ discard_symbol: rb_erase(&pos->rb_node, root); | |||
632 | dso__set_loaded(curr_map->dso, curr_map->type); | 640 | dso__set_loaded(curr_map->dso, curr_map->type); |
633 | } | 641 | } |
634 | 642 | ||
635 | return count; | 643 | return count + moved; |
636 | } | 644 | } |
637 | 645 | ||
638 | int dso__load_kallsyms(struct dso *self, const char *filename, | 646 | int dso__load_kallsyms(struct dso *self, const char *filename, |
@@ -1772,8 +1780,8 @@ out_failure: | |||
1772 | return -1; | 1780 | return -1; |
1773 | } | 1781 | } |
1774 | 1782 | ||
1775 | static int dso__load_vmlinux(struct dso *self, struct map *map, | 1783 | int dso__load_vmlinux(struct dso *self, struct map *map, |
1776 | const char *vmlinux, symbol_filter_t filter) | 1784 | const char *vmlinux, symbol_filter_t filter) |
1777 | { | 1785 | { |
1778 | int err = -1, fd; | 1786 | int err = -1, fd; |
1779 | 1787 | ||
@@ -2123,14 +2131,55 @@ static struct dso *machine__create_kernel(struct machine *self) | |||
2123 | return kernel; | 2131 | return kernel; |
2124 | } | 2132 | } |
2125 | 2133 | ||
2134 | struct process_args { | ||
2135 | u64 start; | ||
2136 | }; | ||
2137 | |||
2138 | static int symbol__in_kernel(void *arg, const char *name, | ||
2139 | char type __used, u64 start) | ||
2140 | { | ||
2141 | struct process_args *args = arg; | ||
2142 | |||
2143 | if (strchr(name, '[')) | ||
2144 | return 0; | ||
2145 | |||
2146 | args->start = start; | ||
2147 | return 1; | ||
2148 | } | ||
2149 | |||
2150 | /* Figure out the start address of kernel map from /proc/kallsyms */ | ||
2151 | static u64 machine__get_kernel_start_addr(struct machine *machine) | ||
2152 | { | ||
2153 | const char *filename; | ||
2154 | char path[PATH_MAX]; | ||
2155 | struct process_args args; | ||
2156 | |||
2157 | if (machine__is_host(machine)) { | ||
2158 | filename = "/proc/kallsyms"; | ||
2159 | } else { | ||
2160 | if (machine__is_default_guest(machine)) | ||
2161 | filename = (char *)symbol_conf.default_guest_kallsyms; | ||
2162 | else { | ||
2163 | sprintf(path, "%s/proc/kallsyms", machine->root_dir); | ||
2164 | filename = path; | ||
2165 | } | ||
2166 | } | ||
2167 | |||
2168 | if (kallsyms__parse(filename, &args, symbol__in_kernel) <= 0) | ||
2169 | return 0; | ||
2170 | |||
2171 | return args.start; | ||
2172 | } | ||
2173 | |||
2126 | int __machine__create_kernel_maps(struct machine *self, struct dso *kernel) | 2174 | int __machine__create_kernel_maps(struct machine *self, struct dso *kernel) |
2127 | { | 2175 | { |
2128 | enum map_type type; | 2176 | enum map_type type; |
2177 | u64 start = machine__get_kernel_start_addr(self); | ||
2129 | 2178 | ||
2130 | for (type = 0; type < MAP__NR_TYPES; ++type) { | 2179 | for (type = 0; type < MAP__NR_TYPES; ++type) { |
2131 | struct kmap *kmap; | 2180 | struct kmap *kmap; |
2132 | 2181 | ||
2133 | self->vmlinux_maps[type] = map__new2(0, kernel, type); | 2182 | self->vmlinux_maps[type] = map__new2(start, kernel, type); |
2134 | if (self->vmlinux_maps[type] == NULL) | 2183 | if (self->vmlinux_maps[type] == NULL) |
2135 | return -1; | 2184 | return -1; |
2136 | 2185 | ||
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h index 038f2201ee09..6c6eafdb932d 100644 --- a/tools/perf/util/symbol.h +++ b/tools/perf/util/symbol.h | |||
@@ -166,6 +166,8 @@ void dso__sort_by_name(struct dso *self, enum map_type type); | |||
166 | struct dso *__dsos__findnew(struct list_head *head, const char *name); | 166 | struct dso *__dsos__findnew(struct list_head *head, const char *name); |
167 | 167 | ||
168 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); | 168 | int dso__load(struct dso *self, struct map *map, symbol_filter_t filter); |
169 | int dso__load_vmlinux(struct dso *self, struct map *map, | ||
170 | const char *vmlinux, symbol_filter_t filter); | ||
169 | int dso__load_vmlinux_path(struct dso *self, struct map *map, | 171 | int dso__load_vmlinux_path(struct dso *self, struct map *map, |
170 | symbol_filter_t filter); | 172 | symbol_filter_t filter); |
171 | int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map, | 173 | int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map, |