On Mon, 2 Apr 2007 14:47:59 +0200
Oliver Neukum <oneukum@suse.de> wrote:
I dont understand why smp_mb() is needed here, and not in spinlock_init() for example.
If you have ordering issues, then the caller of kref_init() should take care of it, not kref_init() itself.
Random example taken in drivers/usb/gadget/file_storage.c :
static int __init fsg_alloc(void)
{
...
kref_init(&fsg->ref);
init_completion(&fsg->thread_notifier);
the_fsg = fsg;
}
In this example, "the_fsg = fsg" memory write might be visible before the memory writes done in init_completion().
Doing a smp_mb() in kref_init() wont help.
AFAIK kref implementation doesnt need this extra smp_mb().
-