Received: by 10.223.185.111 with SMTP id b44csp746997wrg; Fri, 9 Mar 2018 12:59:07 -0800 (PST) X-Google-Smtp-Source: AG47ELvN7316Vpal3/JFxZXKfW9LBmrbDyo8cxu39gDRPkdkK6Bg2zcgzyUUCpKEQyjlmPHTiBzk X-Received: by 2002:a17:902:8d92:: with SMTP id v18-v6mr21731897plo.21.1520629147834; Fri, 09 Mar 2018 12:59:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520629147; cv=none; d=google.com; s=arc-20160816; b=H9whMQ9jZgtY7bRF0wtnVMaemN2hARQ9saIqXMh3DcjYZnOQUr3Mb8r40IVk3RIOb8 T24zf3A8RLJRTdxkO2Zu6bfo85siOMBl4WX9ZMa8407hyd5hhO41dwosb34bX57rfgu5 ZWfE4eTLTlffSjmthAOS9UdZ1cZPKmGQc75+d2uODWMvy7ef7oifq64gDPKqQRgAjLD9 uTmPEYbpsuJgZ+Q+3vbzyLpwPzlop2sqbpmcuSyznbL2Mv8omx6l/kluh+Z4mDcP/6sM kWcUCA5yKrAHYLvIm5saqZz8XVNmzgka8Kiwi90BqYdU0KCMyV06ITIzr+Co0qJOfKJu vbeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=6tZiOBQvNxRRaIrB4uh4SMh8b5QO7EXuWxlf4apmfaQ=; b=RBDuQE+appLI/nRT/QjtCYR3LhDxak2tUJNCKazrH66tgrarKrLREw6BWbSv7LiMJR Szy2u45rmJkQ4RspH8GoxgrvQx8G5GK8Xm0y6e/T7Oh8fs/0NJV33vAKr2pWKzV35I8M 2i4N+k+20H2tNOF0NO2HfOxs+Z/+Gml/JZESNOI03BM5aYalc1G57Lgr644OPdD5h6n+ txf9xXcJXUcBuMpaGkD/En64MDICXujKWS/7N3DTZaxxZXz3Zgkx7DQqpAC/F27KhGP8 wVgd8Aq9y6DVXY9U1rKnwErmSSErEzojOtd5FMfJW8NZaRT1c6L465JZ8TJMvrtngR0C gWNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si1249995pgc.27.2018.03.09.12.58.40; Fri, 09 Mar 2018 12:59:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751880AbeCIU4H (ORCPT + 99 others); Fri, 9 Mar 2018 15:56:07 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43888 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751764AbeCIU4E (ORCPT ); Fri, 9 Mar 2018 15:56:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 74282402599C; Fri, 9 Mar 2018 20:56:03 +0000 (UTC) Received: from krava (ovpn-204-21.brq.redhat.com [10.40.204.21]) by smtp.corp.redhat.com (Postfix) with SMTP id 9389E10AF9CF; Fri, 9 Mar 2018 20:56:01 +0000 (UTC) Date: Fri, 9 Mar 2018 21:56:00 +0100 From: Jiri Olsa To: Leo Yan Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Namhyung Kim , linux-kernel@vger.kernel.org, Mathieu Poirier Subject: Re: [PATCH v2] perf machine: Fix load kernel symbol with '-k' option Message-ID: <20180309205600.GB16890@krava> References: <1520575523-3838-1-git-send-email-leo.yan@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1520575523-3838-1-git-send-email-leo.yan@linaro.org> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 09 Mar 2018 20:56:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Fri, 09 Mar 2018 20:56:03 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jolsa@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 09, 2018 at 02:05:23PM +0800, Leo Yan wrote: > 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, > else > 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, right, the mmap gets confused with the vmlinux path, but I wonder the fix should be not to include symbol_conf.vmlinux_name in the mmap_name like below.. untested thanks, jirka --- diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 43fbbee409ec..f0cb72022177 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -51,15 +51,9 @@ static void machine__threads_init(struct machine *machine) static int machine__set_mmap_name(struct machine *machine) { if (machine__is_host(machine)) { - if (symbol_conf.vmlinux_name) - machine->mmap_name = strdup(symbol_conf.vmlinux_name); - else - machine->mmap_name = strdup("[kernel.kallsyms]"); + machine->mmap_name = strdup("[kernel.kallsyms]"); } else if (machine__is_default_guest(machine)) { - if (symbol_conf.default_guest_vmlinux_name) - machine->mmap_name = strdup(symbol_conf.default_guest_vmlinux_name); - else - machine->mmap_name = strdup("[guest.kernel.kallsyms]"); + machine->mmap_name = strdup("[guest.kernel.kallsyms]"); } else { if (asprintf(&machine->mmap_name, "[guest.kernel.kallsyms.%d]", machine->pid) < 0) @@ -794,9 +788,15 @@ static struct dso *machine__get_kernel(struct machine *machine) struct dso *kernel; if (machine__is_host(machine)) { + if (symbol_conf.vmlinux_name) + vmlinux_name = symbol_conf.vmlinux_name; + kernel = machine__findnew_kernel(machine, vmlinux_name, "[kernel]", DSO_TYPE_KERNEL); } else { + if (symbol_conf.default_guest_vmlinux_name) + vmlinux_name = symbol_conf.default_guest_vmlinux_name; + kernel = machine__findnew_kernel(machine, vmlinux_name, "[guest.kernel]", DSO_TYPE_GUEST_KERNEL);