From: Andrea Parri <andrea.parri@amarulasolutions.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
Will Deacon <will.deacon@arm.com>,
Peter Zijlstra <peterz@infradead.org>,
Boqun Feng <boqun.feng@gmail.com>,
Nicholas Piggin <npiggin@gmail.com>,
David Howells <dhowells@redhat.com>,
Jade Alglave <j.alglave@ucl.ac.uk>,
Luc Maranget <luc.maranget@inria.fr>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Akira Yokosawa <akiyks@gmail.com>,
Daniel Lustig <dlustig@nvidia.com>,
Jonathan Corbet <corbet@lwn.net>, Ingo Molnar <mingo@redhat.com>,
Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH] doc: Update wake_up() & co. memory-barrier guarantees
Date: Tue, 26 Jun 2018 12:11:28 +0200 [thread overview]
Message-ID: <20180626101127.GB8295@andrea> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1806251253380.1779-100000@iolanthe.rowland.org>
> > -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
>
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2018-06-26 10:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-25 9:17 [PATCH] doc: Update wake_up() & co. memory-barrier guarantees Andrea Parri
2018-06-25 9:50 ` Peter Zijlstra
2018-06-25 10:56 ` Andrea Parri
2018-06-25 12:31 ` Peter Zijlstra
2018-06-25 13:16 ` Andrea Parri
2018-06-25 14:18 ` Peter Zijlstra
2018-06-25 14:56 ` Andrea Parri
2018-06-25 15:44 ` Daniel Lustig
2018-06-25 16:38 ` Peter Zijlstra
2018-06-25 16:37 ` Peter Zijlstra
2018-06-26 10:09 ` Andrea Parri
2018-06-26 15:30 ` Peter Zijlstra
2018-06-27 14:15 ` Andrea Parri
2018-06-25 12:12 ` David Howells
2018-06-25 12:28 ` Andrea Parri
2018-06-25 13:00 ` Peter Zijlstra
2018-06-25 16:56 ` Alan Stern
2018-06-26 10:11 ` Andrea Parri [this message]
2018-06-26 13:49 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180626101127.GB8295@andrea \
--to=andrea.parri@amarulasolutions.com \
--cc=akiyks@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=dhowells@redhat.com \
--cc=dlustig@nvidia.com \
--cc=j.alglave@ucl.ac.uk \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=mingo@redhat.com \
--cc=npiggin@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=stern@rowland.harvard.edu \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).