From patchwork Fri Mar 9 06:05:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 131089 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp608586lja; Thu, 8 Mar 2018 22:05:50 -0800 (PST) X-Google-Smtp-Source: AG47ELvOdyZenr078vvaI1iNWghLxvfN4UubAcFJteBXNWcYQRg9fYm6TuEoXR77C1tPxxNmRHHy X-Received: by 2002:a17:902:b683:: with SMTP id c3-v6mr26366994pls.154.1520575550234; Thu, 08 Mar 2018 22:05:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520575550; cv=none; d=google.com; s=arc-20160816; b=LOPvm1Zm4YY9spe7dmuWQ0A1AjRbxK36xcu1WXl4hbPHagZMtRGv0NNk6LDPts8UgU iLuz7MzxAIns8mXQfJALA61MwjdjWPq+1GArxCPadc+S3GilAhYS8r+dMO//KmfP9M2Y gEUKXT+TAkSKMcnsdLwdu7GM8XctdCgSdVhGBVYS6cFqaWkrTGP4i+D6ZkRQ0vPJuXX7 BKAJu/cs22z3OTuckH4xsD11W8ne/T/gGsNT4itJCdFjXxiKfb/hL7temA1xlWF17guf om3GKKrXpbpSA8rZcs29s0JYgCkyzRmQ2tMkASHuO3KeDWZ8j46UlIZeO1Bepl6XZyU1 f2HQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=5gUxE94oylLEhF7rju089OY88qBaWO6EiRIDroFXyDE=; b=r9Buld3ydMLLnruUHl5gLDc16iw14KszBio6+9DI24Tk53NHzWteicK1auDxMTj5/0 64ptRx1NASfck8zzODirRfXvlkXEYj98HDYDfixd3VQW7RWITFwZxsHVKV2i3HMgdfCA XELtnUEtGX+e06h+Ni+xX21kcWHW3ZdzQ0ju1MHeKtGCFQYRxH+bHMxygJRrDCCIIiv2 1EQy3CCKvJ6jvjBgsvN5Mb4aPt3B7ATlTJ4ZkE1OPldszzsLmCyRHNIWnKW9pNLguwTW Ma1r18TbWMWGFvI28Wi5wysQadpw1Wmis0fVzAeqmQRcsbjbrVL/3Ni41CxptukWmoQ4 +nXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZPWHfZjy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10si278324pgr.73.2018.03.08.22.05.49; Thu, 08 Mar 2018 22:05:50 -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; dkim=pass header.i=@linaro.org header.s=google header.b=ZPWHfZjy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751254AbeCIGFq (ORCPT + 28 others); Fri, 9 Mar 2018 01:05:46 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:39144 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbeCIGFn (ORCPT ); Fri, 9 Mar 2018 01:05:43 -0500 Received: by mail-wr0-f195.google.com with SMTP id r66so291389wrb.6 for ; Thu, 08 Mar 2018 22:05:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=5gUxE94oylLEhF7rju089OY88qBaWO6EiRIDroFXyDE=; b=ZPWHfZjyszqt8sbBABilmdTXXZiazm0cZMhdwsRnKeIgc2R2Kqgkxs5yLTkTLKcuQ1 AZsK9IkpSC86Lk2S4nAXvVbXuo+slqAXa2K7/B1D+8VURAjDniz6/4YIqwjgR+2W9Wao eAJY5vrBuz0g+KHngnY6MaPu7QUiJj2zhgX04= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5gUxE94oylLEhF7rju089OY88qBaWO6EiRIDroFXyDE=; b=ddx4clBctrH8gORW+ssFXl3aSS2IkfmsMZVxL6U96TWpLFYpJd5S0rwKTgOu/pbt1X SGGq4KfqbVe/COiUE7gJxizNLhKRDsrethcMQZUclBkc7YyPlM1DRt5gRU3myW2gukBc OeKAVEO3fI4T0cn7/UzD2SFHeW+NqAGbP7FbLfZ+wZl/MQO3lYrFNWDzqojGoIdiYBjE anqQgBO06E01lXoWFNEw2skzkrCSU0tIpoXg+f/j6BfXxEFS0oBVKyVuL7VGQQOWlxZe APm2ExHEcWK5UgKAWcBydiPYnO8LyrMTu84PVGKL+gvbn7bSAoJddGBTxBW5fnQYKigi mSgA== X-Gm-Message-State: APf1xPCBJhyG4BgeXGS06obb9ap3V19Xatd/fpZfIeTyqlSK9x+HmSZB 4zPBLmGNnWnsW0emCKP+tgEQJw== X-Received: by 10.223.224.199 with SMTP id e7mr23052610wri.263.1520575542516; Thu, 08 Mar 2018 22:05:42 -0800 (PST) Received: from localhost.localdomain (li622-172.members.linode.com. [212.71.249.172]) by smtp.gmail.com with ESMTPSA id i49sm325855wra.44.2018.03.08.22.05.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Mar 2018 22:05:41 -0800 (PST) From: Leo Yan To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org, Mathieu Poirier Cc: Leo Yan Subject: [PATCH v2] perf machine: Fix load kernel symbol with '-k' option Date: Fri, 9 Mar 2018 14:05:23 +0800 Message-Id: <1520575523-3838-1-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.4 Reviewed-by: Mathieu Poirier Tested-by: Leo Yan 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,