[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150910175557.GA20640@redhat.com>
Date: Thu, 10 Sep 2015 19:55:57 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Boqun Feng <boqun.feng@...il.com>
Cc: "Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
Jonathan Corbet <corbet@....net>,
Michal Hocko <mhocko@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
David Howells <dhowells@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists