From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932183AbdCFTEo (ORCPT ); Mon, 6 Mar 2017 14:04:44 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59074 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754393AbdCFTEg (ORCPT ); Mon, 6 Mar 2017 14:04:36 -0500 Date: Mon, 6 Mar 2017 21:50:29 +0530 From: "Naveen N. Rao" To: Masami Hiramatsu Cc: linux-kernel@vger.kernel.org, Steven Rostedt , Ingo Molnar , Arnaldo Carvalho de Melo , linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH v4 2/3] perf: kretprobes: offset from reloc_sym if kernel supports it References: <20170304094911.5f96a10a9f075b6f16fe90d3@kernel.org> <20170304113551.6a008b969a3ed713729cbd57@kernel.org> <20170304133405.176da43d40cec7cb00e757e1@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170304133405.176da43d40cec7cb00e757e1@kernel.org> User-Agent: Mutt/1.6.2 (2016-07-01) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17030616-0012-0000-0000-000003C5B223 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030616-0013-0000-0000-00001B4B0189 Message-Id: <20170306162029.GB7467@naverao1-tp.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-06_12:,, 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-1703060137 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017/03/04 01:34PM, Masami Hiramatsu wrote: > On Sat, 4 Mar 2017 11:35:51 +0900 > Masami Hiramatsu wrote: > > > On Sat, 4 Mar 2017 09:49:11 +0900 > > Masami Hiramatsu wrote: > > > > > On Thu, 2 Mar 2017 23:25:06 +0530 > > > "Naveen N. Rao" wrote: > > > > > > > We indicate support for accepting sym+offset with kretprobes through a > > > > line in ftrace README. Parse the same to identify support and choose the > > > > appropriate format for kprobe_events. > > > > > > Could you give us an example of this change here? :) > > > for example, comment of commit 613f050d68a8 . > > > > > > I think the code is OK, but we need actual example of result. > > > > Hi Naveen, > > > > I've tried following commands > > > > $ grep "[Tt] user_read$" /proc/kallsyms > > 0000000000000000 T user_read > > 0000000000000000 t user_read > > $ sudo ./perf probe -D user_read%return > > r:probe/user_read _text+3539616 > > r:probe/user_read_1 _text+3653408 > > > > OK, looks good. However, when I set the retprobes, I got an error. > > > > $ sudo ./perf probe -a user_read%return > > Failed to write event: Invalid argument > > Error: Failed to add events. > > > > And kernel rejected that. > > > > $ dmesg -k | tail -n 1 > > [ 850.315068] Given offset is not valid for return probe. > > > > Hmm, curious.. > > Ah, I see. > > static int create_trace_kprobe(int argc, char **argv) > ... > } else { > /* a symbol specified */ > symbol = argv[1]; > /* TODO: support .init module functions */ > ret = traceprobe_split_symbol_offset(symbol, &offset); > if (ret) { > pr_info("Failed to parse symbol.\n"); > return ret; > } > if (offset && is_return && > !arch_function_offset_within_entry(offset)) { > pr_info("Given offset is not valid for return probe.\n"); > return -EINVAL; > } > } > > So, actually, traceprobe_split_symbol_offset() just split out symbol > and offset from symbol string (e.g. "_text+3539616"). > So, you should use kallsyms_lookup_size_offset() here again to check > offset. Ah, nice catch! I should have tested Steven's patch... > > Please try attached patch (I've already tested on x86-64). > > $ sudo ./perf probe -a user_read%return > Added new events: > probe:user_read (on user_read%return) > probe:user_read_1 (on user_read%return) > > You can now use it in all perf tools, such as: > > perf record -e probe:user_read_1 -aR sleep 1 > > $ sudo ./perf probe -l > probe:user_read (on user_read%return@security/keys/user_defined.c) > probe:user_read_1 (on user_read%return@selinux/ss/policydb.c) > $ sudo cat /sys/kernel/debug/kprobes/list > ffffffff9637bf70 r user_read+0x0 [DISABLED][FTRACE] > ffffffff963602f0 r user_read+0x0 [DISABLED][FTRACE] Thanks, I will test this. - Naveen