From patchwork Tue Feb 27 07:17:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 129744 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp1075334lja; Mon, 26 Feb 2018 23:18:18 -0800 (PST) X-Google-Smtp-Source: AH8x227HQzpjfxG4ycRMA6wxmRZjBUF3oI7ZlxDYRh2dPRnL2HWWoMkBNNsfi1FMuhCR6rNmcvg6 X-Received: by 2002:a17:902:d68e:: with SMTP id v14-v6mr13559906ply.199.1519715898205; Mon, 26 Feb 2018 23:18:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519715898; cv=none; d=google.com; s=arc-20160816; b=KQwH/I4GcO5KkwppOdUPvGiYet04wk4EWDVfox08+utpo+udBKuVFEay4asiYAS3bL 57X+8YHnQykCtmw1JlFAgcoW2JKDZp4RkGxm0hSsUWxWTzxtp0zp+tX+sCY0rf/jnAoE 5+xQWVt5QKrsjAVnb2KSgMlSi6cazMIDo+BhRu9P2WEIbjt2TW8/skTacXM60au3qzaW TGJqbOy9YvIZrQ/VOa28wxuMwJhAEpzS+Xwg3TrCTDOkdcEfL5e5mN1EKk9lDcrEBKGj MAaVCV+jUYI9ZbbrW17ASmp7gRxfOcnL8beXNEvqPWGpLTGL8ltfxSq9eWDfQTmToOEJ GiCw== 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=bXvZjKFnvei+Tc640JSAKf0hnd9ERSqSo8NL7ciGdUc=; b=IzYPKS0nh0FZpXsWjXA7/p1yCVSlP654pBlW+uIaoAOCmPkbp3oOeAoVXcpgj0bmJs DKlYiAqT/HNR+ZZhwWgwMkgWh3pc0VqoZgJboi7UBEvOIMp4BDRKt77Vg4EDtS9LR5qg ZHp0Rg5UA/ZqBNwWE8zqfCctQSB+IWoMylfpRm6cY/Ka/bvPsEF/tsgxJbGcNh51IGz/ 9MDi9xSw/b+lc+9rjoeYI22lxodaCBlUSSRvNPJ33CaJeFd5sHhQp+9A0Flmdc2a7Eja x72Xl1PlSl+qN9l8B47T3Q9UA4UH2Ghnw3P7yL4uWUYvtEogtB3iL1Q++Nh6Llgpdqom r1OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S3XUuf7T; 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 33-v6si8070273pls.710.2018.02.26.23.18.17; Mon, 26 Feb 2018 23:18:18 -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=S3XUuf7T; 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 S1752357AbeB0HSM (ORCPT + 28 others); Tue, 27 Feb 2018 02:18:12 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:35011 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752079AbeB0HSL (ORCPT ); Tue, 27 Feb 2018 02:18:11 -0500 Received: by mail-qt0-f194.google.com with SMTP id z14so4849198qti.2 for ; Mon, 26 Feb 2018 23:18:11 -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=bXvZjKFnvei+Tc640JSAKf0hnd9ERSqSo8NL7ciGdUc=; b=S3XUuf7TsOMsJYMDLAMDvJSCHfNYKYTS1H8ADQYoeVblmZeVCcovGXXYjITFGpWOS+ 6apmiFWap0oCbeA/3sszjwP5WieNITUzq7J/OtVDbJxRytnr7k8ijSRyFh9pVwoplDuF r7/exrdA58O2/mgIL4u7p8ZJcHgATAp6FsLlI= 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=bXvZjKFnvei+Tc640JSAKf0hnd9ERSqSo8NL7ciGdUc=; b=AhpIBEg+e9oaAQYL15V5zlRj7zwgixSDq9Ifh8gIRGxUPtvoDfDMCjJbwWDK/+HLV9 ShBTlp/cfNqRxaduWdfukXe8TIcyNQXcDnTKZp4V+JGxjqiBkd5f62OSX2e3DmSMJYRr RLFHnGy6YPrUswbAuxG62CW0FIZkkKBie7qc/pNDg1cuzxFwYIwycNTqJwmvJmeFwE1k hZ78hJjiiuZZvMscnq2/lxstH+XUa3gGXgtiHV8QMJVNflzmbb9zX1dA+/X1SOQkCg9w E1p8kcQkppzkPP6sXrs8MrhN3pCDbe7EOxmPK272IsD7FJcTP+YnrMZoDqB6ITOqKVKo QC2g== X-Gm-Message-State: APf1xPBBEDneiBPr/FsvBTkQjtMSknf2eOfFncobVgB1MRN+o22rSUSG NypQn1RNUgNMz5wDiTW0GqXeAw== X-Received: by 10.237.41.129 with SMTP id o1mr22024074qtd.2.1519715891038; Mon, 26 Feb 2018 23:18:11 -0800 (PST) Received: from localhost.localdomain ([45.77.212.61]) by smtp.gmail.com with ESMTPSA id 92sm198762qta.5.2018.02.26.23.18.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 23:18:09 -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] perf machine: Fix load kernel symbol with '-k' option Date: Tue, 27 Feb 2018 15:17:52 +0800 Message-Id: <1519715872-31050-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 'machine->mmap_name', when its start char is not '[' then we can know it includes vmlinux path string specified for option '-k'. For this case it sets 'is_kernel_mmap = 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'. Signed-off-by: Leo Yan --- tools/perf/util/machine.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 12b7427..ffd709d 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; + /* + * If machine mmap_name doesn't start with char '[', it includes + * the specified kernel vmlinux name with option '-k'. So set + * is_kernel_mmap as true to create machine symbol map. + */ + if (machine->mmap_name[0] != '[') + 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,