From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5092 invoked by alias); 9 Jul 2007 08:19:01 -0000 Received: (qmail 5059 invoked by uid 22791); 9 Jul 2007 08:18:59 -0000 X-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME X-Spam-Check-By: sourceware.org Received: from rgminet01.oracle.com (HELO rgminet01.oracle.com) (148.87.113.118) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 09 Jul 2007 08:18:56 +0000 Received: from rgmsgw02.us.oracle.com (rgmsgw02.us.oracle.com [138.1.186.52]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id l698IrGj002926 for ; Mon, 9 Jul 2007 02:18:53 -0600 Received: from [10.182.121.157] (dhcp-beijing-cdc-10-182-121-157.cn.oracle.com [10.182.121.157]) by rgmsgw02.us.oracle.com (Switch-3.2.4/Switch-3.2.4) with ESMTP id l698Iowl017523 for ; Mon, 9 Jul 2007 02:18:51 -0600 Message-ID: <4691EF22.2000108@oracle.com> Date: Mon, 09 Jul 2007 08:19:00 -0000 From: Wenji Huang User-Agent: Mozilla Thunderbird 1.0.8-1.4.1 (X11/20060420) X-Accept-Language: en-us, en MIME-Version: 1.0 To: systemtap@sourceware.org Subject: Re: multip register_uprobe References: <468DF726.9090808@oracle.com> <20070706123519.GC31528@linux.vnet.ibm.com> <1183739833.3828.16.camel@dyn9047018076.beaverton.ibm.com> <1183744210.7614.9.camel@dyn9047018076.beaverton.ibm.com> In-Reply-To: <1183744210.7614.9.camel@dyn9047018076.beaverton.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAA== X-Whitelist: TRUE X-Whitelist: TRUE X-IsSubscribed: yes 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 X-SW-Source: 2007-q3/txt/msg00045.txt.bz2 Hi, Jim Got it, I also tried the several cases by changing hander/vaddr, but using same probe. Also works, no problem. Thanks, Wenji Jim Keniston wrote: >On Fri, 2007-07-06 at 09:37 -0700, Jim Keniston wrote: > > >>On Fri, 2007-07-06 at 18:05 +0530, Srikar Dronamraju wrote: >> >> >>>Hi Wenji, >>> >>> >>> >>> >>>> I am creating some test scripts based on sarikar's framework. >>>> >>>> There is one problem about register multiple times. >>>> ................. >>>> probes->vaddr = vaddr; >>>> probes->pid = pid; >>>> probes->handler = handler; >>>> for (i=0; i < 3; i++) { >>>> ret = register_uprobe(probes); >>>> if (ret!=0) //of course, the first time should succeed and >>>>will failed in second time, ret = -16 >>>> { >>>>I tried several possibilities: >>>> >>>> >... > > >>>> * return 0; //RESULT: same as above >>>> >>>> >>The above approach should work, assuming your cleanup function >>unregisters the probe. >> >>You have found a bug. Thanks! I will post a fix shortly. >> >> >> > >Attached are a patch with the fix and a module (wenji3x.c) that >demonstrates the bug (or fix). This patch applies atop the May 26 (GMT) >uprobes patch set. > >Thanks again. >Jim > > >------------------------------------------------------------------------ > > >If register_uprobe() or register_uretprobe() fails while attempting to >register a probe on a process that already has one or more u[ret]probes >in place, subsequent uprobes activity on that process (probe hits, >register/unregister attempts) may hang. Here's a fix. > >--- > > kernel/uprobes.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > >diff -puN kernel/uprobes.c~reused-probe-fix kernel/uprobes.c >--- linux-2.6.21-rc6/kernel/uprobes.c~reused-probe-fix 2007-07-06 09:16:49.000000000 -0700 >+++ linux-2.6.21-rc6-jimk/kernel/uprobes.c 2007-07-06 09:18:56.000000000 -0700 >@@ -830,8 +830,10 @@ fail_uproc: > if (uproc_is_new) { > uprobe_free_process(uproc); > mutex_unlock(&uproc_mutex); >- } else >+ } else { >+ up_write(&uproc->rwsem); > uprobe_put_process(uproc); >+ } > > fail_tsk: > put_task_struct(p); >_ > > >------------------------------------------------------------------------ > >/* uprobe_example.c, modified to try to register the same probe 3 times */ >#include >#include >#include >#include > >/* > * Usage: insmod wenji3x.ko pid= vaddr=
[verbose=0] > * where identifies the probed process and
is the virtual > * address of the probed instruction. > * > * insmod should report success (0) for the first registration attempt > * and failure (-16 = EBUSY) for the second and third attempts. The > * probe should work. > */ > >static int pid = 0; >module_param(pid, int, 0); >MODULE_PARM_DESC(pid, "pid"); > >static int verbose = 1; >module_param(verbose, int, 0); >MODULE_PARM_DESC(verbose, "verbose"); > >static long vaddr = 0; >module_param(vaddr, long, 0); >MODULE_PARM_DESC(vaddr, "vaddr"); > >static int nhits; >static struct uprobe usp; > >static void uprobe_handler(struct uprobe *u, struct pt_regs *regs) >{ > nhits++; > if (verbose) > printk(KERN_INFO "Hit #%d on probepoint at %#lx\n", > nhits, u->vaddr); >} > >int __init init_module(void) >{ > int ret, try, success = 0; > usp.pid = pid; > usp.vaddr = vaddr; > usp.handler = uprobe_handler; > printk(KERN_INFO "Registering uprobe on pid %d, vaddr %#lx\n", > usp.pid, usp.vaddr); > for (try = 1; try <= 3; try++) { > ret = register_uprobe(&usp); > printk(KERN_ERR "Try #%d: register_uprobe() returned %d\n", > try, ret); > if (ret == 0) > success++; > } > return (success ? 0 : ret); >} > >void __exit cleanup_module(void) >{ > printk(KERN_INFO "Unregistering uprobe on pid %d, vaddr %#lx\n", > usp.pid, usp.vaddr); > printk(KERN_INFO "Probepoint was hit %d times\n", nhits); > unregister_uprobe(&usp); >} >MODULE_LICENSE("GPL"); > >