This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: multip register_uprobe


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 ret; //RESULT: the module can't be removed, 
> > the probed process will hang, can't be killed/continued
The above approach is incorrect because you fail the insmod but leave
the probe registered.  (I know, you're trying lots of different
things...)

> >                 * 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.

> >                 * unregister_uprobe(probes);kfree(probes);break; 
> > //RESULT: same as above
The above approach should work, so long as your cleanup function "knows"
that the probes object has been kfreed, and doesn't try to unregister
it.

> >                 * kfree(probes);break; //RESULT: the module can be 
> > removed, the probed process will hang, can't be killed/continued
The above approach is incorrect because you kfree a uprobe that's still
registered.

> >               }
> >         }
> >        return 0;

> > But, no problem in "register once and unregister multiple times".
Yeah, unregistering an already-unregistered probe is treated as a no-op.
This allows your cleanup function to unregister its probes even if the
probed process has exited (at which time uprobes unregisters them on its
own).

> 
> 
> uprobes doesn't allow to register using the same probe structure. 
> Thats currently documented in the Documentation/uprobes.txt
> Under Uprobes features and Limitations. 
> 
> Uprobes may produce unexpected results if you:
> - assign non-zero values to reserved members of struct uprobe;
> - change the contents of a uprobe or uretprobe object while it is
> registered; or
> - attempt to register a uprobe or uretprobe that is already registered.

Correct.  But uprobes should handle such a failure more gracefully.  It
tries to, but in this failure mode, it neglects to unlock uproc->rwsem.

> 
> Please do let me know if I it doesn't answer or if I have misunderstood 
> your query.
> 
> --
> Thanks and Regards
> Srikar 

Thanks.
Jim


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]