Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5554203imm; Sat, 19 May 2018 04:45:57 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoBk8pV0a2xVttTQRgpp0IkqpglJcCaIpuDAsEr/D6HMSMx/ljuRunkoZl2ngiF/8XPbz3C X-Received: by 2002:a17:902:694b:: with SMTP id k11-v6mr13324352plt.334.1526730357255; Sat, 19 May 2018 04:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526730357; cv=none; d=google.com; s=arc-20160816; b=AaFJNs8MoXnFEFjXaxHRHXi17RVoU5A6ISjSW9CdtYKihHsZwAG1XwdHN//1Z6YLbk dLBO1C+PzbVGEdx57u6tR5lRWnnoZy3m1FLZZ9slfILwL2TjIvEH/oW293ZL2Z+//RHA IPqwjUKoRG0L9LWMXPGhA9RvfQCvEeuz1iThRFr5J1h3HWFN84dVUVJp1KTsNQVnJ7Kc GFX7gSAA/Ga4DuX+GGq2pOgg8io5IVn+R4SmbXxm4xtegDaYZxJ1fW8SW53HnY5ITNRg i5lS6r7xVawCFUxqe8Lhh3766jN2dlGkL7v8gbHG0XezDJS7vdBDQEJIN5ViuG/BU8Vq mf0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=2hYm7tdhGWa3HTy3QuR00QylP9EcVdc8CSPRZbukhVI=; b=l72Fb+d/EeACY8L6OiOBUKTkG9fpa1X3tYrILveF3iII+dXrNEDHgfBImf4Snfh7CD v2Nv20owaBj1c5VcfBJr8gAS0NxiGs2sXK9JrZwfopJxahf25f2Z06gVpZSUNk5VfScc 9VVhqZgddk7yixuCSX6XhNp+n1ZOy+ERVll5cin54hg/48cbwqLUtoR/YvolY9vLWm/i 2rCzBmh+rWiIwHOJIDkvj5574jCFwkpDaYCQJSua7TuYWfKW+n1qMzm/+Atr9eeScdjp wPyVPVWK6hsQ6GhGStQlKnNfgnw2YfZ8cG71hXyx/XoIqurUs7hD9JdHQ31UKVFZ6+V+ fB0g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r12-v6si9475515plo.442.2018.05.19.04.45.43; Sat, 19 May 2018 04:45:57 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752573AbeESLpU (ORCPT + 99 others); Sat, 19 May 2018 07:45:20 -0400 Received: from terminus.zytor.com ([198.137.202.136]:33611 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752201AbeESLpR (ORCPT ); Sat, 19 May 2018 07:45:17 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id w4JBj9aQ2801410 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 19 May 2018 04:45:09 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w4JBj99i2801407; Sat, 19 May 2018 04:45:09 -0700 Date: Sat, 19 May 2018 04:45:09 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Sandipan Das Message-ID: Cc: acme@redhat.com, naveen.n.rao@linux.vnet.ibm.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@redhat.com, hpa@zytor.com, ravi.bangoria@linux.ibm.com, sandipan@linux.vnet.ibm.com Reply-To: linux-kernel@vger.kernel.org, jolsa@redhat.com, hpa@zytor.com, ravi.bangoria@linux.ibm.com, sandipan@linux.vnet.ibm.com, acme@redhat.com, naveen.n.rao@linux.vnet.ibm.com, tglx@linutronix.de, mingo@kernel.org In-Reply-To: <20180517063326.6319-1-sandipan@linux.vnet.ibm.com> References: <20180517063326.6319-1-sandipan@linux.vnet.ibm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf script: Show virtual addresses instead of offsets Git-Commit-ID: 19610184693c547b4c12738df4156589892c4018 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 19610184693c547b4c12738df4156589892c4018 Gitweb: https://git.kernel.org/tip/19610184693c547b4c12738df4156589892c4018 Author: Sandipan Das AuthorDate: Thu, 17 May 2018 12:03:25 +0530 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 17 May 2018 16:55:29 -0300 perf script: Show virtual addresses instead of offsets When perf data is recorded with the call-graph option enabled, the callchain shown by perf script shows the binary offsets of the symbols as the ip. This is incorrect for kernel symbols as the ip values are always off by a fixed offset depending on the architecture. If the offsets from the start of the symbols are printed, they are also incorrect for both kernel and userspace symbols. Without the call-graph option, the callchain shows the virtual addresses of the symbols rather than their binary offsets. The offsets printed in this case are also correct. This fixes the inconsistency in perf script's output. This can be verified on a powerpc64le system running Fedora 27 as follows: # cat /proc/kallsyms | grep sys_write ... c0000000004025a0 T sys_write c0000000004025a0 T __se_sys_write ... # perf probe -a sys_write Before applying this patch: # perf record -e probe:sys_write -g ~/test # perf script -F ip,sym,symoff 4125b0 sys_write+0x8000000000008010 1b9e0 system_call+0x8000000000008058 118234 __GI___libc_write+0xffff0000f52c0024 92c74 _IO_file_write@@GLIBC_2.17+0xffff0000f52c0044 5afbfd8a [unknown] 91a60 new_do_write+0xffff0000f52c0090 94638 _IO_do_write@@GLIBC_2.17+0xffff0000f52c0038 94bbc _IO_file_overflow@@GLIBC_2.17+0xffff0000f52c014c 95a24 __overflow+0xffff0000f52c0064 84548 _IO_puts+0xffff0000f52c0218 440 main+0xffffffffe0000020 236a0 generic_start_main.isra.0+0xffff0000f52c0140 23898 __libc_start_main+0xffff0000f52c00b8 0 [unknown] ... # perf record -e probe:sys_write ~/test # perf script -F ip,sym,symoff c0000000004025b0 sys_write+0x10 ... After applying this patch: # perf record -e probe:sys_write -g ~/test # perf script -F ip,sym,symoff c0000000004025b0 sys_write+0x10 c00000000000b9e0 system_call+0x58 7fffb70d8234 __GI___libc_write+0x24 7fffb7052c74 _IO_file_write@@GLIBC_2.17+0x44 5afc1818 [unknown] 7fffb7051a60 new_do_write+0x90 7fffb7054638 _IO_do_write@@GLIBC_2.17+0x38 7fffb7054bbc _IO_file_overflow@@GLIBC_2.17+0x14c 7fffb7055a24 __overflow+0x64 7fffb7044548 _IO_puts+0x218 10000440 main+0x20 7fffb6fe36a0 generic_start_main.isra.0+0x140 7fffb6fe3898 __libc_start_main+0xb8 0 [unknown] ... # perf record -e probe:sys_write ~/test # perf script -F ip,sym,symoff c0000000004025b0 sys_write+0x10 ... Signed-off-by: Sandipan Das Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Naveen N. Rao Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/20180517063326.6319-1-sandipan@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/machine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 72a351613d85..7c777cb32806 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1764,7 +1764,7 @@ static int add_callchain_ip(struct thread *thread, } srcline = callchain_srcline(al.map, al.sym, al.addr); - return callchain_cursor_append(cursor, al.addr, al.map, al.sym, + return callchain_cursor_append(cursor, ip, al.map, al.sym, branch, flags, nr_loop_iter, iter_cycles, branch_from, srcline); }