From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757613AbcAUEo4 (ORCPT ); Wed, 20 Jan 2016 23:44:56 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:39604 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756680AbcAUEoz (ORCPT ); Wed, 20 Jan 2016 23:44:55 -0500 Message-ID: <56A061D8.80502@huawei.com> Date: Thu, 21 Jan 2016 12:43:04 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Arnaldo Carvalho de Melo , Ben Hutchings , Masami Hiramatsu , He Kuang CC: Peter Zijlstra , Ingo Molnar , , Jiri Olsa , Kaixu Xia , Zefan Li Subject: Re: [PATCH perf 3/4] perf tools: Fix unused variables: x86_{32,64}_regoffset_table References: <20160119213213.GB2637@decadent.org.uk> <20160119213306.GE2637@decadent.org.uk> <20160120135924.GR27085@kernel.org> In-Reply-To: <20160120135924.GR27085@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.56A061ED.0001,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: a95e417b74f4136717ebb0df3c41fe89 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/1/20 21:59, Arnaldo Carvalho de Melo wrote: > Em Tue, Jan 19, 2016 at 09:33:06PM +0000, Ben Hutchings escreveu: >> gcc 5 doesn't seem to care about these, but gcc 6 does and that >> results in a build failure. > Ben, please CC the people on the CC list for the patch that introduces > the problem, Wang, He, can I have your Acked-by? > > - Arnaldo > This patch lead me find a bug in original code. If both perf and target ELF binary is x86_64, following command works okay: # perf probe -v -n --exec /tmp/oxygen_root/lib64/libc.so.6 pselect data exceptfds readfds writefds nfds sigmask tval timeout Opening /sys/kernel/debug/tracing//uprobe_events write=1 Writing event: p:probe_libc/pselect /home/w00229757/oxygen_root-w00229757/lib64/libc-2.18.so:0xdfef0 data=-216(%sp):u64 exceptfds=%cx:u64 readfds=%si:u64 writefds=%dx:u64 nfds=%di:s32 sigmask=%r9:u64 tval=-232(%sp):u64 timeout=%r8:u64 But if the library is x86_32, result is incorrect: # perf probe -v -n --exec /tmp/oxygen_root/lib32/libc.so.6 pselect data exceptfds readfds writefds nfds sigmask tval Writing event: p:probe_libc/pselect /tmp/oxygen_root-w00229757/lib32/libc-2.18.so:0xd1330 data=-172(%si):u64 exceptfds=+16(%si):u32 readfds=+8(%si):u32 writefds=+12(%si):u32 nfds=+4(%si):s32 sigmask=+24(%si):u32 tval=-180(%si):u64 timeout=+20(%si):u32 We know that (%si) is used to passing arguments. Here we should see '%sp' or '$stack'. Use a x86_32 perf we get currect result: # ~/perf probe -v -n --exec /tmp/oxygen_root/lib32/libc.so.6 pselect data exceptfds readfds writefds nfds sigmask tval Writing event: p:probe_libc/pselect /tmp/oxygen_root-w00229757/lib32/libc-2.18.so:0xd1330 data=-172($stack):u64 exceptfds=+16($stack):u32 readfds=+8($stack):u32 writefds=+12($stack):u32 nfds=+4($stack):s32 sigmask=+24($stack):u32 tval=-180($stack):u64 Use a small test program to check the result: #include #include #include #include static struct { fd_set r, w, e; struct timespec ts; sigset_t m; } s; int main() { memset(&s, '\0', sizeof(s)); pselect(0, &s.r, &s.w, &s.e, &s.ts, &s.m); return 0; } # gcc -m32 -g ./test_pselect.c Use x86_32 perf: # ./perf probe -v --exec /tmp/oxygen_root/lib32/libc.so.6 pselect data exceptfds readfds writefds nfds sigmask tval Writing event: p:probe_libc/pselect /tmp/oxygen_root-w00229757/lib32/libc-2.18.so:0xd1330 data=-172($stack):u64 exceptfds=+16($stack):u32 readfds=+8($stack):u32 writefds=+12($stack):u32 nfds=+4($stack):s32 sigmask=+24($stack):u32 tval=-180($stack):u64 Added new event: probe_libc:pselect (on pselect in /tmp/oxygen_root-w00229757/lib32/libc-2.18.so with data exceptfds readfds writefds nfds sigmask tval) You can now use it in all perf tools, such as: perf record -e probe_libc:pselect -aR sleep 1 # ./perf record -e probe_libc:pselect ./a.out [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ] # ./perf script a.out 25336 [006] 64588.457597: probe_libc:pselect: (f7663330) data=0xf772e00000000000 exceptfds=0x8049880 readfds=0x8049780 writefds=0x8049800 nfds=0 sigmask=0x8049908 tval=0x0 Switch to x86_64 perf: # ./perf probe -v --exec /tmp/oxygen_root/lib32/libc.so.6 pselect data exceptfds readfds writefds nfds sigmask tval Opening /sys/kernel/debug/tracing//uprobe_events write=1 Writing event: p:probe_libc/pselect /tmp/oxygen_root-w00229757/lib32/libc-2.18.so:0xd1330 data=-172(%si):u64 exceptfds=+16(%si):u32 readfds=+8(%si):u32 writefds=+12(%si):u32 nfds=+4(%si):s32 sigmask=+24(%si):u32 tval=-180(%si):u64 Added new event: probe_libc:pselect (on pselect in /tmp/oxygen_root-w00229757/lib32/libc-2.18.so with data exceptfds readfds writefds nfds sigmask tval) You can now use it in all perf tools, such as: perf record -e probe_libc:pselect -aR sleep 1 # ./perf record -e probe_libc:pselect ./a.out [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.011 MB perf.data (1 samples) ] # ./perf script a.out 25599 [002] 64759.743554: probe_libc:pselect: (f76e7330) data=0x0 exceptfds=0x0 readfds=0x0 writefds=0x0 nfds=0 sigmask=0x0 tval=0x0 Sad... I think this problem is not introduced by my patch. In fact there's a fundamental problem in get_arch_regstr() that it is impossible to switch sub ISA. Not only x86_64 and x86_32, I think on arm64 we also have this problem when we try to setup uprobes on arm32 code. For me the later problem is more important because there are many legacy arm32 applications on Android platform (and I have already seen the buggy unwind result in this case. It is another problem though). So I suggest us to solve this problem first before considering gcc 6 Werror. At least x86_32_regoffset_table and x86_64_regoffset_table should both be compiled no matter which ISA we select for perf. Thank you.