Re: wake_up_process implied memory barrier clarification

From: Michal Hocko
Date: Thu Aug 27 2015 - 09:14:52 EST


On Thu 27-08-15 14:43:34, Peter Zijlstra wrote:
> On Thu, Aug 27, 2015 at 02:27:27PM +0200, Michal Hocko wrote:
> > Hi,
> > I have just stumbled over the comment above wake_up_process which
> > claims:
> > "
> > * It may be assumed that this function implies a write memory barrier before
> > * changing the task state if and only if any tasks are woken up.
> > "
> >
> > but try_to_wake_up does smp_mb__before_spinlock and did smp_wmb
> > since 04e2f1741d235 unconditionally. The comment was added when the
> > smp_wmb was in place already so I am wondering whether the comment is
> > wrong/misleading.
> >
> > Could somebody clarify please?
>
> Its true for wake_up(), since that bails early if the waitqueue list is
> empty.
>
> I suspect there was no exception made for wake_up_process() to simplify
> the rules.

Thanks for the confirmation. Shouldn't we rather change the
documentation because this is clearly misleading and confusing.
---