[lttng-dev] [PATCH] Expose kernel tracer to user-space

Francis Giraldeau francis.giraldeau at gmail.com
Tue Jun 26 10:52:01 EDT 2012

Le 2012-06-26 08:40, Mathieu Desnoyers a écrit :
>> +/*
>> + * lttng_uevent_set_handler - set handler functions for uevent
>> + *
>> + * Access to handler code is protected with rwlock in order to
>> + * prevent the optional module to be removed while in use.
>> + */
>> +
>> +void lttng_uevent_set_handler(write_ops_t handler)
>> +{
>> +	write_lock(&uevent_rwlock);
> write lock not necessary.
> if (!lttng_uevent_set_handler)
>   release refcount in prior handler's module.
> then:
> take a refcount on the module that contains the handler address.
> (explicit)

The function now looks like this:

void lttng_uevent_set_handler(struct file_operations *fops)
	if (lttng_uevent_handler) {
	if (fops && try_module_get(fops->owner)) {
		lttng_uevent_handler = fops;
	lttng_uevent_handler = NULL;

The problem with this approach is that lttng_uevent can't be unloaded

  rmmod lttng_uevent
  ERROR: Module lttng_uevent is in use

The module lttng_uevent can't be unloaded without unloading the module
lttng_tracer. The function module_exit of lttng_uevent is never called,
such that there is a chicken-and-egg situation. This problem was solved
by using rwlock to access the handler pointer. In the rare event when
unload module would occur while a trace event is recorded, the write
lock was preventing to change the handler pointer while it's in use. But
maybe there is another way to do it?


Francis Giraldeau

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4476 bytes
Desc: Signature cryptographique S/MIME
URL: <http://lists.lttng.org/pipermail/lttng-dev/attachments/20120626/3dcfc15b/attachment.bin>

More information about the lttng-dev mailing list