Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1730048imm; Tue, 10 Jul 2018 07:02:19 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdbgxNs6AK8qrpKuHmNhGDzk143ahrIcs56kW7NEb+C/jlrIqkEKTcBTAF4GeQruP1c0m/C X-Received: by 2002:a17:902:1005:: with SMTP id b5-v6mr25153132pla.207.1531231339420; Tue, 10 Jul 2018 07:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531231339; cv=none; d=google.com; s=arc-20160816; b=Xe0LETyCvGjva3JpcmxaV2QlhWgKFLyy955fiJRNKj6rq7B71GQr4zyoQ362RXxjHi SIU4GlSwPVlja5f26VhNm/bj9xdKGaJOPUFY67LPStn7xnjmFDW4muVzpvRh7lxPg1MQ oWMU8j4LB82W0fO1bgYq9wQatq7EcclKRpwKQRhWOapqUnMzAmrcXAfgmPFgk+hStjhC A/HpLwk0U1g5Eo9nx6jjqbiSJMWMtOoOaLyvJ1DvyiPINwmU9nkQ8WYmto9MHjl2U1WE IRiABdtJ9v7WXhZ19fSqrXMQNCLkEiuTQRLCq3Nu+XS9m3KuU92KilyaBVq5J/yUYDHD aNhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to :references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=/cdHEzmhe3uWQKYlaY80zB88/A6DM/jbmXz5N1BEr2E=; b=Qt01+5UWI4P6rj7brAwmRUubFskWEHViEmRV/I9C3wbkO8zDgZ7uuXpEiZaNoA+1Px Dx2vNRF4Ov6vZwr+KeelyNbIDEk76bHxo9c7GiHufc+dVhh8d1269R6tJjt25cMs5LQj Ehash1XTa+7Vh7pID3lg/zS3m3B/0AmuRNGcLjHIMdCbdpWbASo3oX6KZvmgTs9YDzhv M6AMk5EgBn8SYPPNwIDG6frdKgXQu2NgvTVl25zJDuNdC66DpIEtiWVhmUyu+Yjs9HBP 0kQVwd6CODxJ8DEI01hrg/pL7ghRHVH3IHxkkyz8ElxZ/JSdkJALama4E0suP3uzAeUQ hVGQ== 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 q2-v6si16715845plh.136.2018.07.10.07.01.42; Tue, 10 Jul 2018 07:02:19 -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 S933655AbeGJN7e (ORCPT + 99 others); Tue, 10 Jul 2018 09:59:34 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52874 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933216AbeGJN63 (ORCPT ); Tue, 10 Jul 2018 09:58:29 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6ADsp76104689 for ; Tue, 10 Jul 2018 09:58:29 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k4x288kb5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 10 Jul 2018 09:58:29 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 10 Jul 2018 14:58:26 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 10 Jul 2018 14:58:25 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6ADwOps35454992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Jul 2018 13:58:24 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65CDB11C04C; Tue, 10 Jul 2018 16:58:46 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 165BF11C05B; Tue, 10 Jul 2018 16:58:45 +0100 (BST) Received: from localhost.localdomain (unknown [9.195.22.129]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 10 Jul 2018 16:58:44 +0100 (BST) From: Sandipan Das To: acme@kernel.org Cc: linux-kernel@vger.kernel.org, jolsa@redhat.com, ravi.bangoria@linux.vnet.ibm.com, naveen.n.rao@linux.vnet.ibm.com, sukadev@linux.vnet.ibm.com, maynard@us.ibm.com Subject: [PATCH 2/5] perf powerpc: Fix callchain ip filtering when return address is in a register Date: Tue, 10 Jul 2018 19:28:14 +0530 X-Mailer: git-send-email 2.14.4 In-Reply-To: References: In-Reply-To: References: X-TM-AS-GCONF: 00 x-cbid: 18071013-0020-0000-0000-000002A4F985 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18071013-0021-0000-0000-000020F13A14 Message-Id: <66e848a7bdf2d43b39210a705ff6d828a0865661.1530724939.git.sandipan@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-10_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807100151 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For powerpc64, perf will filter out the second entry in the callchain, i.e. the LR value, if the return address of the function corresponding to the probed location has already been saved on its caller's stack. The state of the return address is determined using debug information. At any point within a function, if the return address is already saved somewhere, a DWARF expression can tell us about its location. If the return address in still in LR only, no DWARF expression would exist. Typically, the instructions in a function's prologue first copy the LR value to R0 and then pushes R0 on to the stack. If LR has already been copied to R0 but R0 is yet to be pushed to the stack, we can still get a DWARF expression that says that the return address is in R0. This is indicating that getting a DWARF expression for the return address does not guarantee the fact that it has already been saved on the stack. This can be observed on a powerpc64le system running Fedora 27 as shown below. # objdump -d /usr/lib64/libc-2.26.so | less ... 000000000015af20 : 15af20: 0b 00 4c 3c addis r2,r12,11 15af24: e0 c1 42 38 addi r2,r2,-15904 15af28: a6 02 08 7c mflr r0 15af2c: f0 ff c1 fb std r30,-16(r1) 15af30: f8 ff e1 fb std r31,-8(r1) 15af34: 78 1b 7f 7c mr r31,r3 15af38: 78 23 83 7c mr r3,r4 15af3c: 78 2b be 7c mr r30,r5 15af40: 10 00 01 f8 std r0,16(r1) 15af44: c1 ff 21 f8 stdu r1,-64(r1) 15af48: 28 00 81 f8 std r4,40(r1) ... # readelf --debug-dump=frames-interp /usr/lib64/libc-2.26.so | less ... 00027024 0000000000000024 00027028 FDE cie=00000000 pc=000000000015af20..000000000015af88 LOC CFA r30 r31 ra 000000000015af20 r1+0 u u u 000000000015af34 r1+0 c-16 c-8 r0 000000000015af48 r1+64 c-16 c-8 c+16 000000000015af5c r1+0 c-16 c-8 c+16 000000000015af78 r1+0 u u ... # perf probe -x /usr/lib64/libc-2.26.so -a inet_pton+0x18 # perf record -e probe_libc:inet_pton -g ping -6 -c 1 ::1 # perf script Before: ping 2829 [005] 512917.460174: probe_libc:inet_pton: (7fff7e2baf38) 7fff7e2baf38 __GI___inet_pton+0x18 (/usr/lib64/libc-2.26.so) 7fff7e2705b4 getaddrinfo+0x164 (/usr/lib64/libc-2.26.so) 12f152d70 _init+0xbfc (/usr/bin/ping) 7fff7e1836a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so) 7fff7e183898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so) 0 [unknown] ([unknown]) After: ping 2829 [005] 512917.460174: probe_libc:inet_pton: (7fff7e2baf38) 7fff7e2baf38 __GI___inet_pton+0x18 (/usr/lib64/libc-2.26.so) 7fff7e26fa54 gaih_inet.constprop.7+0xf44 (/usr/lib64/libc-2.26.so) 7fff7e2705b4 getaddrinfo+0x164 (/usr/lib64/libc-2.26.so) 12f152d70 _init+0xbfc (/usr/bin/ping) 7fff7e1836a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so) 7fff7e183898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so) 0 [unknown] ([unknown]) Reported-by: Ravi Bangoria Signed-off-by: Sandipan Das --- tools/perf/arch/powerpc/util/skip-callchain-idx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/arch/powerpc/util/skip-callchain-idx.c b/tools/perf/arch/powerpc/util/skip-callchain-idx.c index 264fc0158100..7c6eeb4633fe 100644 --- a/tools/perf/arch/powerpc/util/skip-callchain-idx.c +++ b/tools/perf/arch/powerpc/util/skip-callchain-idx.c @@ -58,9 +58,13 @@ static int check_return_reg(int ra_regno, Dwarf_Frame *frame) } /* - * Check if return address is on the stack. + * Check if return address is on the stack. If return address + * is in a register (typically R0), it is yet to be saved on + * the stack. */ - if (nops != 0 || ops != NULL) + if ((nops != 0 || ops != NULL) && + !(nops == 1 && ops[0].atom == DW_OP_regx && + ops[0].number2 == 0 && ops[0].offset == 0)) return 0; /* -- 2.14.4