unregistering kretprobe mid-function (was: stpd issues)

Jim Keniston jkenisto@us.ibm.com
Tue Aug 23 18:25:00 GMT 2005


On Sat, 2005-08-20 at 04:23, Frank Ch. Eigler wrote:
> hiet wrote:
> 
> > [...]  I observed some issues with the new transport with the
> > attached module (insert jprobes and kretprobes on all system
> > calls). [...]
> 
> I wonder what happens if one has a kretprobe on an cunning function
> (sys_delete_module), which indirectly may end up trying to remove the
> probe (unregister_kretprobe) during its execution (systemtap probe
> cleanup).  In other words, how does the kretprobe logic handle the
> removal function, when the entry half of a return probe has been hit,
> and the return part is pending?
> 
> - FChE

This situation is covered.  A kretprobe_instance object always hangs
around until the function returns.  If the kretprobe is unregistered
before the probed function returns, the instance's kretprobe pointer is
set to NULL.  When the function returns, no handler is run but the
instance is freed.

Attached is a test to verify that.  It should print the following lines
on /var/log/messages:

... kernel: kretunreg: register_kretprobe returns 0
... kernel: nret = 4, sum = 65
... kernel: kretunreg: register_kretprobe returns 0
... kernel: nret = 4, sum = 65

Jim
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kretunreg.c
Type: text/x-c
Size: 1198 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/systemtap/attachments/20050823/7f36bbb0/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kretunreg_ppc64.c
Type: text/x-c
Size: 1253 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/systemtap/attachments/20050823/7f36bbb0/attachment-0001.bin>


More information about the Systemtap mailing list