From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62958 invoked by alias); 16 Dec 2015 13:10:36 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 62944 invoked by uid 89); 16 Dec 2015 13:10:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 16 Dec 2015 13:10:34 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id E9620C0B930C; Wed, 16 Dec 2015 13:10:32 +0000 (UTC) Received: from [10.10.53.65] (vpn-53-65.rdu2.redhat.com [10.10.53.65]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBGDAWif005961; Wed, 16 Dec 2015 08:10:32 -0500 Subject: Re: Recent aarch64 kprobes and uprobes patch systemtap testing To: Pratyush Anand References: <5669DF98.3030601@redhat.com> <5669EABE.7040507@linaro.org> <566B3949.2090900@redhat.com> <20151216115528.GB316@dhcppc13.redhat.com> Cc: David Long , systemtap@sourceware.org From: William Cohen Message-ID: <567162C8.6020508@redhat.com> Date: Wed, 16 Dec 2015 13:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151216115528.GB316@dhcppc13.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-q4/txt/msg00290.txt.bz2 On 12/16/2015 06:55 AM, Pratyush Anand wrote: > On 11/12/2015:03:59:53 PM, William Cohen wrote: >> Hi Dave and Pratyush, >> >> I did some more experimentation with the fslatency-nd and fsslow-nd tests to see what is going on. The problem seems to be related to the return probes. I have a small reproducer attached which runs fine on x86_64 machine. However on aarch64 it has the bogus read because some of the argument registers have changed value >> >> # ../install/bin/stap ./aarch64_retkprobe_issue2.stp >> ERROR: read fault [man error::fault] at 0x0000000000000034 (addr) near operator '@cast' at ./aarch64_retkprobe_issue2.stp:13:7 >> pc : [] lr : [] pstate: 80000145 >> sp : fffffe00bad7be30 >> x29: fffffe00bad7be30 x28: fffffe00bad78000 >> x27: fffffe0000912000 x26: 000000000000003f >> x25: 000000000000011d x24: 0000000000000015 >> x23: 0000000080000000 x22: 000003fff82b9760 >> x21: fffffe00bad7bec8 x20: 0000000000002004 >> x19: fffffe01b716e100 x18: 000003fff82b8160 >> x17: 000003ff849bf0a0 x16: fffffe000021f4a0 >> x15: 0000000000000004 x14: 000003fff82bb910 >> x13: 0000000000000001 x12: 000003ff7d75f200 >> x11: 00000000003d0f00 x10: 000003ff849b7af4 >> x9 : 0000000000000028 x8 : 0000000000000020 >> x7 : fffffe00bc5c3600 x6 : 0000000000000000 >> x5 : 0000000000000000 x4 : 0000000000000000 >> x3 : fffffe00bad7bec8 x2 : 0000000000002004 >> x1 : 000003fff82b9760 x0 : fffffe01b716e100 >> >> pc : [] lr : [] pstate: 60000145 >> sp : fffffe00bad7be30 >> x29: fffffe00bad7be30 x28: fffffe00bad78000 >> x27: fffffe0000912000 x26: 000000000000003f >> x25: 000000000000011d x24: 0000000000000015 >> x23: 0000000080000000 x22: 000003fff82b9760 >> x21: fffffe00bad7bec8 x20: 0000000000002004 >> x19: fffffe01b716e100 x18: 000003fff82b8160 >> x17: 000003ff849bf0a0 x16: fffffe000021f4a0 >> x15: 0000000000000004 x14: 000003fff82bb910 >> x13: 0000000000000001 x12: 000003ff7d75f200 >> x11: 00000000003d0f00 x10: 000003ff849b7af4 >> x9 : 0000000000000028 x8 : 0000000000000020 >> x7 : fffffe00bc5c3600 x6 : 000003fff82b976c >> x5 : 000003fff82b976c x4 : 0000000000000000 >> x3 : 0000000000000000 x2 : 0000000000000000 >> x1 : 0000000000000000 x0 : 000000000000000c > > Although I am not sure, but this is what it seems to me: > > First argument (file) is in x0, and which is 0xC in case of kretprobe. But, can > x0 really be considered as 1st arg in case of kretprobe? > I think, x0 should have return value of __vfs_read() in case of kretprobe. So, > 0xC could be the number of bytes read. > > With perf I see: > > # perf probe -k vmlinux __vfs_read_exit=__vfs_read%return file > Semantic error :You can't specify local variable for kretprobe. > > So, I am not sure what mechanism systemtap uses to get local variable in case of > kretprobe. > > Moreover, on x86 I see that loop exits after the 1st print_regs() only. So it > means there was valid file->f_op->read() for the 1st file itself. If I comment > "kprobe.function("__vfs_read")", then there is no print at all. It means, we are > not hitting a case on x86 when callback was called for kretprobe and we had > nonzero 1st argument. > > ~Pratyush > Hi Pratyush, I found that the problem was that the systemtap scripts assumed x86_64 behavior where the arguments passed into the function are in memory and are still around on return. For aarch64 (and other architectures that pass arguments via registers) the registers holding the values get clobbered. I checked in a fix into the exampls to address this problem: https://sourceware.org/git/gitweb.cgi?p=systemtap.git;a=commit;h=3d0c2f452f09a64b800aabe68508f8f0183f0ea1 I also filed a systemtap bug to look for this issue in other places in systemtap: https://sourceware.org/bugzilla/show_bug.cgi?id=19360 -Will