Re: CPU ordering with respect to krefs

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Oliver Neukum <oneukum@...>
Cc: Greg KH <gregkh@...>, <linux-kernel@...>
Date: Monday, April 2, 2007 - 10:33 am

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().

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
CPU ordering with respect to krefs, Oliver Neukum, (Mon Apr 2, 8:47 am)
Re: CPU ordering with respect to krefs, Eric Dumazet, (Mon Apr 2, 10:33 am)
Re: CPU ordering with respect to krefs, Greg KH, (Thu Apr 12, 2:27 am)
Re: CPU ordering with respect to krefs, Oliver Neukum, (Tue Apr 17, 1:44 am)