From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755489AbdDFDpn (ORCPT ); Wed, 5 Apr 2017 23:45:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40727 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754187AbdDFDpf (ORCPT ); Wed, 5 Apr 2017 23:45:35 -0400 Reply-To: pc@us.ibm.com Subject: Re: [PATCH v3] Allow user probes on versioned symbols References: <20170331173123.GA18286@kernel.org> <095e1578-81c6-c62a-007f-1238445406a1@us.ibm.com> <20170403144658.GA3744@kernel.org> <20170404231802.711ac3e3346fa786259ddcde@kernel.org> <20170404142604.GB12903@kernel.org> To: Arnaldo Carvalho de Melo , Masami Hiramatsu Cc: LKML , David Ahern , linux-perf-users From: Paul Clarke Date: Wed, 5 Apr 2017 22:45:29 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170404142604.GB12903@kernel.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17040603-0028-0000-0000-0000075B2FE7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006887; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00843730; UDB=6.00415750; IPR=6.00621904; BA=6.00005271; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014930; XFM=3.00000013; UTC=2017-04-06 03:45:33 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17040603-0029-0000-0000-000034E07AAB Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-06_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704060030 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/04/2017 09:26 AM, Arnaldo Carvalho de Melo wrote: > Em Tue, Apr 04, 2017 at 11:18:02PM +0900, Masami Hiramatsu escreveu: >> On Mon, 3 Apr 2017 11:46:58 -0300 >> Arnaldo Carvalho de Melo wrote: >> > > > But apart from those problems, I think that one should be able to ask >> > > > for a versioned symbol, to probe just apps using that specific version, >> > >> > > I agree, but wasn't trying to tackle that at the moment. I can look into it, though. >> > >> > > > for instance, we should consider the whole name as two functions, which >> > > > in fact, they are, no? >> > >> > > I'm not sure I understand what you mean here. Do you mean we should set a probe at every version of a given symbol name? For example, if there are symbols: >> > > a@@V2 >> > > a@V1.1 >> > > a@V1 >> > >> > > ...for a request to set a probe at "a", we'd actually set a probe at all 3? >> > >> > I think that we should just probe the default for that symbol and have a >> > way to probe all of them, perhaps using the wildcard, i.e.: >> > >> > [root@jouet linux]# nm /lib64/libpthread-2.24.so | grep ' pthread_cond_timedwait' >> > 000000000000dd90 T pthread_cond_timedwait@GLIBC_2.2.5 >> > 000000000000d6e0 T pthread_cond_timedwait@@GLIBC_2.3.2 >> > [root@jouet linux]# >> > >> > # perf probe -x /lib64/libpthread-2.24.so pthread_cond_timedwait >> > >> > should be equivalent to: >> > >> > # perf probe -x /lib64/libpthread-2.24.so pthread_cond_timedwait@@GLIBC_2.3.2 >> > >> > Which matches how these versioned symbols are resolved by the linker, >> > no? >> > >> > I.e. when 'pthread_cond_timedwait' is specified and the symbol table >> > lookup fails, I think we should re-lookup for >> > 'pthread_cond_timedwait@@*', i.e. we should have a >> > symbol__find_default_by_name(), which will take the >> > "pthread_cond_timedwait" and use a symbol comparison using >> > strncmp(strlen(key)), matching, should then look at right after the >> > common part looking for the double @@. > >> Hm, this 'fallback'process sounds good idea to me. I just sent a patch that does what you suggest, above. To avoid duplicating the code in symbols_find_by_name, I added a parameter to tell it whether to ignore default symbol tags or not. > This is just trying to keep the semantics used by the original user of > this syntax, i.e. the linker. > >> BTW, how would we support other SYMBOL@VERSION, since we already >> use '@' for specifying source code? >> One possible way is to support it directly in perf-probe. If it >> failed to find probe point from dwarf, try to find from symbol >> map by using '@VERSION' suffix. > > Right, we would be overloading that @ symbol, since version numbers > usually are very different of file source names :-) There's not a lot of syntactic difference between "file" and "tag". I don't think there is any standard for what either can be. One might expect a "file" to be name.extension, where extension is a finite set (possibly fairly large). A tag can be almost anything, I think. One might expect it to end with a number. I don't think there's a guarantee of either case, though. It would seem one way to determine whether it's a file or a tag is to try to find it in the symbol tables. If it's not there, assume it's a file. (Or vice-versa.) PC