aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2010-01-05 13:50:31 -0500
committerIngo Molnar <mingo@elte.hu>2010-01-13 04:09:11 -0500
commit56b03f3c4d641dbdbce2e52a2969712e85b0e030 (patch)
tree3c15eb7ed163ca63bed395b233535f6fca2cccec /tools/perf/util/symbol.c
parentb9a63b9b56d6910a25e3d4905525aef150420a9b (diff)
perf tools: Handle relocatable kernels
DSOs don't have this problem because the kernel emits a PERF_MMAP for each new executable mapping it performs on monitored threads. To fix the kernel case we simulate the same behaviour, by having 'perf record' to synthesize a PERF_MMAP for the kernel, encoded like this: [root@doppio ~]# perf record -a -f sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.344 MB perf.data (~15038 samples) ] [root@doppio ~]# perf report -D | head -10 0xd0 [0x40]: event: 1 . . ... raw event: size 64 bytes . 0000: 01 00 00 00 00 00 40 00 00 00 00 00 00 00 00 00 ......@........ . 0010: 00 00 00 81 ff ff ff ff 00 00 00 00 00 00 00 00 ............... . 0020: 00 00 00 00 00 00 00 00 5b 6b 65 72 6e 65 6c 2e ........ [kernel . 0030: 6b 61 6c 6c 73 79 6d 73 2e 5f 74 65 78 74 5d 00 kallsyms._text] . 0xd0 [0x40]: PERF_RECORD_MMAP 0/0: [0xffffffff81000000((nil)) @ (nil)]: [kernel.kallsyms._text] I.e. we identify such event as having: .pid = 0 .filename = [kernel.kallsyms.REFNAME] .start = REFNAME addr in /proc/kallsyms at 'perf record' time and use now a hardcoded value of '.text' for REFNAME. Then, later, in 'perf report', if there are any kernel hits and thus we need to resolve kernel symbols, we search for REFNAME and if its address changed, relocation happened and we thus must change the kernel mapping routines to one that uses .pgoff as the relocation to apply. This way we use the same mechanism used for the other DSOs and don't have to do a two pass in all the kernel symbols. Reported-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frédéric Weisbecker <fweisbec@gmail.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> LKML-Reference: <1262717431-1246-1-git-send-email-acme@infradead.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/symbol.c')
-rw-r--r--tools/perf/util/symbol.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index e290429e9c00..da2f07f1af8f 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -956,11 +956,15 @@ static int dso__load_sym(struct dso *self, struct map *map,
956 956
957 elf_symtab__for_each_symbol(syms, nr_syms, idx, sym) { 957 elf_symtab__for_each_symbol(syms, nr_syms, idx, sym) {
958 struct symbol *f; 958 struct symbol *f;
959 const char *elf_name; 959 const char *elf_name = elf_sym__name(&sym, symstrs);
960 char *demangled = NULL; 960 char *demangled = NULL;
961 int is_label = elf_sym__is_label(&sym); 961 int is_label = elf_sym__is_label(&sym);
962 const char *section_name; 962 const char *section_name;
963 963
964 if (kernel && session->ref_reloc_sym.name != NULL &&
965 strcmp(elf_name, session->ref_reloc_sym.name) == 0)
966 perf_session__reloc_vmlinux_maps(session, sym.st_value);
967
964 if (!is_label && !elf_sym__is_a(&sym, map->type)) 968 if (!is_label && !elf_sym__is_a(&sym, map->type))
965 continue; 969 continue;
966 970
@@ -973,7 +977,6 @@ static int dso__load_sym(struct dso *self, struct map *map,
973 if (is_label && !elf_sec__is_a(&shdr, secstrs, map->type)) 977 if (is_label && !elf_sec__is_a(&shdr, secstrs, map->type))
974 continue; 978 continue;
975 979
976 elf_name = elf_sym__name(&sym, symstrs);
977 section_name = elf_sec__name(&shdr, secstrs); 980 section_name = elf_sec__name(&shdr, secstrs);
978 981
979 if (kernel || kmodule) { 982 if (kernel || kmodule) {