[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180626101127.GB8295@andrea>
Date: Tue, 26 Jun 2018 12:11:28 +0200
From: Andrea Parri <andrea.parri@...rulasolutions.com>
To: Alan Stern <stern@...land.harvard.edu>
Cc: linux-kernel@...r.kernel.org, linux-doc@...r.kernel.org,
Will Deacon <will.deacon@....com>,
Peter Zijlstra <peterz@...radead.org>,
Boqun Feng <boqun.feng@...il.com>,
Nicholas Piggin <npiggin@...il.com>,
David Howells <dhowells@...hat.com>,
Jade Alglave <j.alglave@....ac.uk>,
Luc Maranget <luc.maranget@...ia.fr>,
"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
Akira Yokosawa <akiyks@...il.com>,
Daniel Lustig <dlustig@...dia.com>,
Jonathan Corbet <corbet@....net>,
Ingo Molnar <mingo@...hat.com>,
Randy Dunlap <rdunlap@...radead.org>
Subject: Re: [PATCH] doc: Update wake_up() & co. memory-barrier guarantees
> > -A write memory barrier is implied by wake_up() and co. if and only if they
> > -wake something up. The barrier occurs before the task state is cleared, and so
> > -sits between the STORE to indicate the event and the STORE to set TASK_RUNNING:
> > +A general memory barrier is executed by wake_up() if it wakes something up.
> > +If it doesn't wake anything up then a memory barrier may or may not be
> > +executed; you must not rely on it. The barrier occurs before the task state
> > +is accessed, in part., it sits between the STORE to indicate the event and
> > +the STORE to set TASK_RUNNING:
>
> Minor suggestion: Instead of "in part.", how about "that is"?
>
> (I generally find "in part." to be at least a little confusing,
> probably because "part" is itself a word and "in part" is a
> reasonably common phrase in English.)
Mmh, the fact is that that "before the task state is accessed" does want
to include the LOAD from ->state to check for the task state (recall the
pattern in [1])...; how about if I expand "in part." to "in particular"?
>
> >
> > - CPU 1 CPU 2
> > + CPU 1 (Sleeper) CPU 2 (Waker)
> > =============================== ===============================
> > set_current_state(); STORE event_indicated
> > smp_store_mb(); wake_up();
> > - STORE current->state <write barrier>
> > - <general barrier> STORE current->state
> > - LOAD event_indicated
> > + STORE current->state ...
> > + <general barrier> <general barrier>
> > + LOAD event_indicated if ((LOAD task->state) & TASK_NORMAL)
> > + STORE task->state
> >
> > -To repeat, this write memory barrier is present if and only if something
> > -is actually awakened. To see this, consider the following sequence of
> > -events, where X and Y are both initially zero:
> > +where "task" is the thread being woken up and it equals CPU 1's current.
>
> Since "task" is in quotation marks, "current" should also be in
> quotation marks.
Sure, will fix in v2.
Thanks,
Andrea
>
> Alan
>
Powered by blists - more mailing lists