Re: [PATCH] It may not be assumed that wake_up(), finish_wait() andco. imply a memory barrier

From: Linus Torvalds
Date: Thu Apr 23 2009 - 13:13:24 EST




On Thu, 23 Apr 2009, David Howells wrote:
>
> I was wondering if wake_up() and friends should in fact imply smp_wmb(), but I
> guess that they're often used in conjunction with spinlocks - and in such a
> situation a barrier is unnecessary overhead.

I think we _have_ to imply a smp_wmb() in the wakup semantics, because
otherwise sleepers can't do anything sane (no amount of barriers on the
sleeping side will help). IOW, there basically has to be an implied write
barrier between the thing that causes an event to become true, and the
thing that turns 'task->state' back to RUNNING.

This is similar to the issue of doing cross-CPU IPI's: sending an IPI
_must_ imply a memory barrier with the IPI mechanism, because otherwise
the receiver could never do anything sane.

Linus
--
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/