Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752858AbcDZJRG (ORCPT ); Tue, 26 Apr 2016 05:17:06 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:8620 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbcDZJRB (ORCPT ); Tue, 26 Apr 2016 05:17:01 -0400 Subject: Re: [RFC] perf probe: Fix offline module name missmatch issue To: Ravi Bangoria , Masami Hiramatsu References: <1461580708-15169-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> <20160426062438.aea663884cf5bd95f766f2d5@kernel.org> <571F2D50.4010305@linux.vnet.ibm.com> CC: , , , , , , , , From: "Wangnan (F)" Message-ID: <571F31BF.7030304@huawei.com> Date: Tue, 26 Apr 2016 17:15:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <571F2D50.4010305@linux.vnet.ibm.com> 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.0A020204.571F3208.016D,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: 64c9ca2d1a48d79d9538c95ef7f923a4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2707 Lines: 80 On 2016/4/26 16:56, Ravi Bangoria wrote: > Thanks Masami for reviewing. > > Please find my replies to your comment. > > On Tuesday 26 April 2016 02:54 AM, Masami Hiramatsu wrote: >> Hi Ravi, >> >> On Mon, 25 Apr 2016 16:08:27 +0530 >> Ravi Bangoria wrote: >> >>> Perf can add a probe on kernel module which has not been loaded yet. >>> Current implementation finds module name from path. But if filename >>> is different from actual module name then perf fails to register >>> probe while loading module because of mismatch in names. For example, >>> samples/kobject/kobject-example.ko is loaded as kobject_example. >> Ah! right, good catch! >> Have some comment below; >> >>> diff --git a/tools/perf/util/probe-event.c >>> b/tools/perf/util/probe-event.c >>> index 8319fbb..05d0905 100644 >>> --- a/tools/perf/util/probe-event.c >>> +++ b/tools/perf/util/probe-event.c >>> @@ -265,6 +265,65 @@ static bool kprobe_warn_out_range(const char >>> *symbol, unsigned long address) >>> return true; >>> } >>> +/* >>> + * NOTE: >>> + * '.gnu.linkonce.this_module' section of kernel module elf directly >>> + * maps to 'struct module' from linux/module.h. This section contains >>> + * actual module name which will be used by kernel after loading it. >>> + * But, we cannot use 'struct module' here since linux/module.h is not >>> + * exposed to user-space. Offset of 'name' has remained same from long >>> + * time, so hardcoding it here. >>> + */ >>> +#ifdef __LP64__ >>> +#define MOD_NAME_OFFSET 24 >>> +#else >>> +#define MOD_NAME_OFFSET 12 >>> +#endif >>> + >>> +/* >>> + * @module can be module name of module file path. In case of path, >>> + * inspect elf and find out what is actual module name. >>> + * Caller has to free mod_name after using it. >>> + */ >>> +char *find_module_name(const char *module) >> Could you make this function static, since there is no caller outside >> this file? > > Yes. no caller outside of this file. But, > > In this patch, function find_module_name is defined outside of > #ifdef HAVE_DWARF_SUPPORT while it's being called from inside of > #ifdef HAVE_DWARF_SUPPORT. > > If I make it static and if there is no dwarf support, there will be > compilation > error about function defined but not used. > > And in second patch("perf probe: Fix module probe issue if no dwarf > support"), > I'm calling it from outside of #ifdef HAVE_DWARF_SUPPORT. > > So I have two options: > 1. merge both the patches and make definition as static > 2. make function static in second patch > > I've chose second approach and sent v2. But please let me know if > there is > better way to do it. > Try __maybe_unused directive? Thank you.