Pārlūkot izejas kodu

perf kmem: Fixup the symbol address before using it

We get absolute addresses in the events, but relative ones from the
symbol subsystem, so calculate the absolute address by asking for the
map where the symbol was found, that has the place where the DSO was
actually loaded.

For the core kernel this poses no problems if the kernel is not
relocated by things like kexec, or if we use /proc/kallsyms, but for
modules we were getting really large, negative offsets.

LKML-Reference: <new-submission>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Arnaldo Carvalho de Melo 15 gadi atpakaļ
vecāks
revīzija
71cf8b8ff7
1 mainītis faili ar 3 papildinājumiem un 2 dzēšanām
  1. 3 2
      tools/perf/builtin-kmem.c

+ 3 - 2
tools/perf/builtin-kmem.c

@@ -363,6 +363,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
 		struct alloc_stat *data = rb_entry(next, struct alloc_stat,
 		struct alloc_stat *data = rb_entry(next, struct alloc_stat,
 						   node);
 						   node);
 		struct symbol *sym = NULL;
 		struct symbol *sym = NULL;
+		struct map *map;
 		char buf[BUFSIZ];
 		char buf[BUFSIZ];
 		u64 addr;
 		u64 addr;
 
 
@@ -370,13 +371,13 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
 			addr = data->call_site;
 			addr = data->call_site;
 			if (!raw_ip)
 			if (!raw_ip)
 				sym = map_groups__find_function(&session->kmaps,
 				sym = map_groups__find_function(&session->kmaps,
-								addr, NULL, NULL);
+								addr, &map, NULL);
 		} else
 		} else
 			addr = data->ptr;
 			addr = data->ptr;
 
 
 		if (sym != NULL)
 		if (sym != NULL)
 			snprintf(buf, sizeof(buf), "%s+%Lx", sym->name,
 			snprintf(buf, sizeof(buf), "%s+%Lx", sym->name,
-				 addr - sym->start);
+				 addr - map->unmap_ip(map, sym->start));
 		else
 		else
 			snprintf(buf, sizeof(buf), "%#Lx", addr);
 			snprintf(buf, sizeof(buf), "%#Lx", addr);
 		printf(" %-34s |", buf);
 		printf(" %-34s |", buf);