Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2914237imm; Wed, 16 May 2018 23:35:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo4Yg7rDduxczTNHKJCqYGukFrOI2U7QUJqFelH3c8XW7xS3SXVV0Cp03M/h2HPu5JxHRqt X-Received: by 2002:a63:6ac6:: with SMTP id f189-v6mr3203247pgc.308.1526538921071; Wed, 16 May 2018 23:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526538921; cv=none; d=google.com; s=arc-20160816; b=1LUdmc46anzyuBqHWarbRpe1wMmH4YHK8ZcnmqG3BTRIeSpXZ7I3LXmk9/EhFr7roS NcnvmvsO10nF5VErsK8BMDcj5ISQOxt/XEobqHURZxIXNj64c0dJ3vvmfZaFgOybAiNd BA9y8pg3ndwYp9mnHhcNuQ+3K8nGW/XMBTrEyWBAB7SZbmXt9L/LUkZZrH+nBk3txdrO 8Ubq2xPgxL/wbmA51+4zprIeRtO7kDuLHrsgU11LYZvTUCRIwTeMg8vaenqqBOYrzcbQ xwF8zWmp9/8toY778PUBhpZFpEydhO4PiwwnjNEFxqvqOkzvgyZjMUxpIH4/ohWdVtYV 1gkQ== 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 :arc-authentication-results; bh=ON3ZPiMCETQIhR5YECeibaA1cJ07lGh04Q896u8f0/0=; b=eGZO4kl9PkrNfLZ4ne8g66RDcrvS6mUFNjjkRNZ7cn0HE5VSceebNI0qiFWnt/T39D CGwDfl404Q8TEet36EyRvxMIVN+tPzb8Q31UQK9Io/AGsF4Sboa28V5I0yDkuyb4Oz2Z meSiUQANcgV65A990+iYYdfjW2HmB491gEdQ81Ac1IkwQWl8BzSbAU2+6bjK+9SRQ94H aF7OT91/lpoYU05mwD7AHbYOrHyG4Cy3WeBlsIVrBsMCVdIcGkwNbjn+/Tta3BRHNjmL Bmsa15VYI5H7gWkYn5+XwgF2sM+/eOx4CJrExokJGDsSMUutroXqDYHqrETEqWALmPJp Xu9w== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1-v6si4140815pln.437.2018.05.16.23.35.06; Wed, 16 May 2018 23:35:21 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752260AbeEQGdf (ORCPT + 99 others); Thu, 17 May 2018 02:33:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39842 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751967AbeEQGdd (ORCPT ); Thu, 17 May 2018 02:33:33 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4H6TmAk129164 for ; Thu, 17 May 2018 02:33:33 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j13ucsr5w-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 May 2018 02:33:32 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 May 2018 07:33:31 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 17 May 2018 07:33:29 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4H6XSh82228672; Thu, 17 May 2018 06:33:28 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8860C4203F; Thu, 17 May 2018 07:24:19 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A821442041; Thu, 17 May 2018 07:24:18 +0100 (BST) Received: from localhost.localdomain (unknown [9.40.193.84]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 17 May 2018 07:24:18 +0100 (BST) From: Sandipan Das To: acme@kernel.org, jolsa@redhat.com Cc: linux-kernel@vger.kernel.org, ravi.bangoria@linux.ibm.com, naveen.n.rao@linux.vnet.ibm.com Subject: [PATCH 1/2] perf script: Show virtual addresses instead of offsets Date: Thu, 17 May 2018 12:03:25 +0530 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 18051706-0008-0000-0000-000004F75D80 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051706-0009-0000-0000-00001E8BD034 Message-Id: <20180517063326.6319-1-sandipan@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-17_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805170059 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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); } -- 2.14.3