[lkml]   [2018]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH v2] perf machine: Fix load kernel symbol with '-k' option
On Hikey arm64 octa A53 platform, when use command './perf report -v
-k vmlinux --stdio' it outputs below error info, and it skips to load
kernel symbol and doesn't print symbol for event:
Failed to open [kernel.kallsyms]_text, continuing without symbols.

The regression is introduced by commit ("8c7f1bb37b29 perf machine: Move
kernel mmap name into struct machine"), which changes the logic for
machine mmap_name by removing function machine__mmap_name() and always
use 'machine->mmap_name'. Comparing difference between
machine__mmap_name() and 'machine->mmap_name', the later one includes
the string for specified kernel vmlinux string with option '-k' in
command, but the old function machine__mmap_name() ignores vmlinux
path string. As result, event's mmap file name doesn't match with
machine mmap file name anymore and it skips to load kernel symbol from
vmlinux file.

To resolve this issue, this patch adds extra checking for
'symbol_conf.vmlinux_name', when it has been set string so we can know
it includes vmlinux path string specified for option '-k'. For this
case it sets 'is_kernel_mmap' to true and run into flow to load kernel
symbol from vmlinux.

This patch has been verified with two commands: './perf report -v
-k vmlinux --stdio' and './perf script -v -F cpu,event,ip,sym,symoff
-k vmlinux'.

Suggested-by: Mathieu Poirier <>
Signed-off-by: Leo Yan <>
tools/perf/util/machine.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 12b7427..3125871 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1299,9 +1299,18 @@ static int machine__process_kernel_mmap_event(struct machine *machine,
kernel_type = DSO_TYPE_GUEST_KERNEL;

- is_kernel_mmap = memcmp(event->mmap.filename,
- machine->mmap_name,
- strlen(machine->mmap_name) - 1) == 0;
+ /*
+ * When symbol_conf.vmlinux_name is not NULL, it includes the specified
+ * kernel vmlinux path with option '-k'. So set 'is_kernel_mmap' to
+ * true for creating machine symbol map.
+ */
+ if (symbol_conf.vmlinux_name)
+ is_kernel_mmap = true;
+ else
+ is_kernel_mmap = memcmp(event->mmap.filename,
+ machine->mmap_name,
+ strlen(machine->mmap_name) - 1) == 0;
if (event->mmap.filename[0] == '/' ||
(!is_kernel_mmap && event->mmap.filename[0] == '[')) {
map = machine__findnew_module_map(machine, event->mmap.start,
 \ /
  Last update: 2018-03-09 07:07    [W:0.054 / U:1.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site