This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
RE: module function probe
- From: "Keshavamurthy, Anil S" <anil dot s dot keshavamurthy at intel dot com>
- To: "Frank Ch. Eigler" <fche at redhat dot com>, "Mao, Bibo" <bibo dot mao at intel dot com>
- Cc: <systemtap at sources dot redhat dot com>
- Date: Wed, 30 Nov 2005 13:16:55 -0800
- Subject: RE: module function probe
Please see my comments.
>-----Original Message-----
>From: systemtap-owner@sourceware.org
>[mailto:systemtap-owner@sourceware.org] On Behalf Of Frank Ch. Eigler
>Sent: Friday, November 25, 2005 4:37 AM
>To: Mao, Bibo
>Cc: systemtap@sources.redhat.com
>Subject: Re: module function probe
>
>Hi -
>
>> I wrote one module named probed.ko after compiled, and the other
>> is kprobe module named probing.ko which is to probe some function
>> defined in probed.ko module.
>> [...]
>> #insmod probed.ko
>> #insmod probing.ko
>> #rmmod probed.ko
>> #rmmod probing.ko
>> [...]
>
>To manage module reference counts in a way that prevents this problem,
>systemtap keeps a file descriptor open on some file under
>/sys/module/<PROBED>/. By using plain insmod, you are giving up this
>protection.
I think we should implement this module reference count
logic built in the kernel kprobes code.
Here is how it can be done.
register_kprobe(...)
{
.....
+ if ((mod = module_text_address((unsigned long) p->addr)))
+ if (unlikely(!try_module_get(mod))) return -EINVAL;
....
}
Unregister_kprobe(...)
{
....
+ module_put(module_text_address((unsigned long)p->addr));
...
}
Opened a bugzilla
http://sources.redhat.com/bugzilla/show_bug.cgi?id=1954
Cheers,
Anil Keshavamurthy