Messages in this thread | | | Date | Thu, 10 Sep 2015 19:55:57 +0200 | From | Oleg Nesterov <> | Subject | Re: [PATCH] Documentation: Remove misleading examples of the barriers in wake_*() |
| |
On 09/10, Boqun Feng wrote: > > On Wed, Sep 09, 2015 at 12:28:22PM -0700, Paul E. McKenney wrote: > > My feeling is > > that we should avoid saying too much about the internals of wait_event() > > and wake_up().
I feel the same. I simply can't understand what we are trying to document ;)
For example,
> A STORE-LOAD barrier is implied after setting task state by wait-related functions: > > prepare_to_wait(); > prepare_to_wait_exclusive(); > prepare_to_wait_event();
I won't argue, but to me this looks misleading too.
Yes, prepare_to_wait()->set_current_state() implies mb() and thus a STORE-LOAD barrier.
But this has nothing to do with the explanation above. We do not need this barrier to avoid the race with wake_up(). Again, again, we can safely rely on wq->lock and acquire/release semantics.
This barrier is only needed if you do, say,
CONDITION = 1;
if (waitqueue_active(wq)) wake_up(wq);
And note that the code above is wrong without another mb() after CONDITION = 1.
Oleg.
| |