diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2014-01-29 09:14:40 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-01-31 15:21:50 -0500 |
commit | 0ae617bedde062003fd70e566e9a2601e273ea0e (patch) | |
tree | 46f48ed62e86133821aba1ae993c8c3d77fbf1fb /tools | |
parent | 5512cf24bed2de56f1ef44b6cc9a0a9b15499cea (diff) |
perf record: Get ref_reloc_sym from kernel map
Now that ref_reloc_sym is set up when the kernel map is created,
'perf record' does not need to pass the symbol names to
perf_event__synthesize_kernel_mmap() which can read the values needed
from ref_reloc_sym directly.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Jiri Olsa <jolsa@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1391004884-10334-6-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/builtin-record.c | 10 | ||||
-rw-r--r-- | tools/perf/util/event.c | 26 | ||||
-rw-r--r-- | tools/perf/util/event.h | 3 |
3 files changed, 9 insertions, 30 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 3c394bf16fa8..af47531b82ec 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -287,10 +287,7 @@ static void perf_event__synthesize_guest_os(struct machine *machine, void *data) | |||
287 | * have no _text sometimes. | 287 | * have no _text sometimes. |
288 | */ | 288 | */ |
289 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | 289 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, |
290 | machine, "_text"); | 290 | machine); |
291 | if (err < 0) | ||
292 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | ||
293 | machine, "_stext"); | ||
294 | if (err < 0) | 291 | if (err < 0) |
295 | pr_err("Couldn't record guest kernel [%d]'s reference" | 292 | pr_err("Couldn't record guest kernel [%d]'s reference" |
296 | " relocation symbol.\n", machine->pid); | 293 | " relocation symbol.\n", machine->pid); |
@@ -457,10 +454,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) | |||
457 | } | 454 | } |
458 | 455 | ||
459 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | 456 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, |
460 | machine, "_text"); | 457 | machine); |
461 | if (err < 0) | ||
462 | err = perf_event__synthesize_kernel_mmap(tool, process_synthesized_event, | ||
463 | machine, "_stext"); | ||
464 | if (err < 0) | 458 | if (err < 0) |
465 | pr_err("Couldn't record kernel reference relocation symbol\n" | 459 | pr_err("Couldn't record kernel reference relocation symbol\n" |
466 | "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" | 460 | "Symbol resolution may be skewed if relocation was used (e.g. kexec).\n" |
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 17476df5c7b2..b0f3ca850e9e 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c | |||
@@ -483,15 +483,13 @@ u64 kallsyms__get_function_start(const char *kallsyms_filename, | |||
483 | 483 | ||
484 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, | 484 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
485 | perf_event__handler_t process, | 485 | perf_event__handler_t process, |
486 | struct machine *machine, | 486 | struct machine *machine) |
487 | const char *symbol_name) | ||
488 | { | 487 | { |
489 | size_t size; | 488 | size_t size; |
490 | const char *filename, *mmap_name; | 489 | const char *mmap_name; |
491 | char path[PATH_MAX]; | ||
492 | char name_buff[PATH_MAX]; | 490 | char name_buff[PATH_MAX]; |
493 | struct map *map; | 491 | struct map *map; |
494 | u64 start; | 492 | struct kmap *kmap; |
495 | int err; | 493 | int err; |
496 | /* | 494 | /* |
497 | * We should get this from /sys/kernel/sections/.text, but till that is | 495 | * We should get this from /sys/kernel/sections/.text, but till that is |
@@ -513,31 +511,19 @@ int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, | |||
513 | * see kernel/perf_event.c __perf_event_mmap | 511 | * see kernel/perf_event.c __perf_event_mmap |
514 | */ | 512 | */ |
515 | event->header.misc = PERF_RECORD_MISC_KERNEL; | 513 | event->header.misc = PERF_RECORD_MISC_KERNEL; |
516 | filename = "/proc/kallsyms"; | ||
517 | } else { | 514 | } else { |
518 | event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL; | 515 | event->header.misc = PERF_RECORD_MISC_GUEST_KERNEL; |
519 | if (machine__is_default_guest(machine)) | ||
520 | filename = (char *) symbol_conf.default_guest_kallsyms; | ||
521 | else { | ||
522 | sprintf(path, "%s/proc/kallsyms", machine->root_dir); | ||
523 | filename = path; | ||
524 | } | ||
525 | } | ||
526 | |||
527 | start = kallsyms__get_function_start(filename, symbol_name); | ||
528 | if (!start) { | ||
529 | free(event); | ||
530 | return -ENOENT; | ||
531 | } | 516 | } |
532 | 517 | ||
533 | map = machine->vmlinux_maps[MAP__FUNCTION]; | 518 | map = machine->vmlinux_maps[MAP__FUNCTION]; |
519 | kmap = map__kmap(map); | ||
534 | size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), | 520 | size = snprintf(event->mmap.filename, sizeof(event->mmap.filename), |
535 | "%s%s", mmap_name, symbol_name) + 1; | 521 | "%s%s", mmap_name, kmap->ref_reloc_sym->name) + 1; |
536 | size = PERF_ALIGN(size, sizeof(u64)); | 522 | size = PERF_ALIGN(size, sizeof(u64)); |
537 | event->mmap.header.type = PERF_RECORD_MMAP; | 523 | event->mmap.header.type = PERF_RECORD_MMAP; |
538 | event->mmap.header.size = (sizeof(event->mmap) - | 524 | event->mmap.header.size = (sizeof(event->mmap) - |
539 | (sizeof(event->mmap.filename) - size) + machine->id_hdr_size); | 525 | (sizeof(event->mmap.filename) - size) + machine->id_hdr_size); |
540 | event->mmap.pgoff = start; | 526 | event->mmap.pgoff = kmap->ref_reloc_sym->addr; |
541 | event->mmap.start = map->start; | 527 | event->mmap.start = map->start; |
542 | event->mmap.len = map->end - event->mmap.start; | 528 | event->mmap.len = map->end - event->mmap.start; |
543 | event->mmap.pid = machine->pid; | 529 | event->mmap.pid = machine->pid; |
diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 66a0c0392863..851fa06f4a42 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h | |||
@@ -214,8 +214,7 @@ int perf_event__synthesize_threads(struct perf_tool *tool, | |||
214 | struct machine *machine, bool mmap_data); | 214 | struct machine *machine, bool mmap_data); |
215 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, | 215 | int perf_event__synthesize_kernel_mmap(struct perf_tool *tool, |
216 | perf_event__handler_t process, | 216 | perf_event__handler_t process, |
217 | struct machine *machine, | 217 | struct machine *machine); |
218 | const char *symbol_name); | ||
219 | 218 | ||
220 | int perf_event__synthesize_modules(struct perf_tool *tool, | 219 | int perf_event__synthesize_modules(struct perf_tool *tool, |
221 | perf_event__handler_t process, | 220 | perf_event__handler_t process, |