perf probe: Fix getting the kernel map
authorAdrian Hunter <[email protected]>
Mon, 4 Mar 2019 13:13:21 +0000 (15:13 +0200)
committerArnaldo Carvalho de Melo <[email protected]>
Mon, 11 Mar 2019 14:56:03 +0000 (11:56 -0300)
Since commit 4d99e4136580 ("perf machine: Workaround missing maps for
x86 PTI entry trampolines"), perf tools has been creating more than one
kernel map, however 'perf probe' assumed there could be only one.

Fix by using machine__kernel_map() to get the main kernel map.

Signed-off-by: Adrian Hunter <[email protected]>
Tested-by: Joseph Qi <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Jiufei Xue <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: Xu Yu <[email protected]>
Fixes: 4d99e4136580 ("perf machine: Workaround missing maps for x86 PTI entry trampolines")
Fixes: d83212d5dd67 ("kallsyms, x86: Export addresses of PTI entry trampolines")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/util/probe-event.c

index a1b8d9649ca737abf09c24934cb8af8b78821e82..198e09ff611e48cecce9ae3795f0a7c8a63c2c27 100644 (file)
@@ -160,8 +160,10 @@ static struct map *kernel_get_module_map(const char *module)
        if (module && strchr(module, '/'))
                return dso__new_map(module);
 
-       if (!module)
-               module = "kernel";
+       if (!module) {
+               pos = machine__kernel_map(host_machine);
+               return map__get(pos);
+       }
 
        for (pos = maps__first(maps); pos; pos = map__next(pos)) {
                /* short_name is "[module]" */