Re: contention on profile_lock

From: John Levon
Date: Thu Nov 04 2004 - 16:54:55 EST


On Thu, Nov 04, 2004 at 12:49:21PM -0800, Jesse Barnes wrote:

> John pointed out that this breaks modules. Would registering and
> unregistering a function pointer thus be module safe? Dipankar, hopefully
> you have something better?
>
> static int timer_start(void)
> {
> /* Setup the callback pointer */
> oprofile_timer_notify = oprofile_timer;
> return 0;
> }

Surely something like (profile.c):

funcptr_t timer_hook;

static int register_timer_hook(funcptr_t hook)
{
if (timer_hook)
return -EBUSY;
timer_hook = hook;
}

static void unregister_timer_hook(funcptr_t hook)
{
WARN_ON(hook != timer_hook);
timer_hook = NULL;
/* make sure all CPUs see the NULL hook */
synchronize_kernel();
}

john
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/