From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Josh Triplett <josh@joshtriplett.org>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
rostedt <rostedt@goodmis.org>,
Nicholas Miell <nmiell@comcast.net>,
Ingo Molnar <mingo@redhat.com>,
One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
Lai Jiangshan <laijs@cn.fujitsu.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
David Howells <dhowells@redhat.com>,
bobby prani <bobby.prani@gmail.com>,
Michael Kerrisk <mtk.manpages@gmail.com>,
Shuah Khan <shuahkh@osg.samsung.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC PATCH] membarrier: handle nohz_full with expedited thread registration
Date: Tue, 17 Jan 2017 02:09:38 +0000 (UTC) [thread overview]
Message-ID: <792537721.5599.1484618978163.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <CA+55aFz-U2DSJZ_7RG1n1TjLcZ5uzsVOF2S8jqKmx8=jn8mS_A@mail.gmail.com>
----- On Jan 16, 2017, at 6:50 PM, Linus Torvalds torvalds@linux-foundation.org wrote:
> Why not just make the write be a "smp_store_release()", and the read
> be a "smp_load_acquire()". That guarantees a certain amount of
> ordering. The only amount that I suspect makes sense, in fact.
>
> But it's not clear what the problem is, so..
If we only use a smp_store_release() for the store to membarrier_exped,
the "unregister" (setting back to 0) would be OK, but not the "register",
as the following scenario shows:
Initial values:
A = B = 0
CPU 0 | CPU 1 (no-hz full)
|
| membarrier(REGISTER_EXPEDITED)
| (write barrier implied by store-release)
| set t->membarrier_exped = 1 (store-release imply memory barrier before store)
| store B = 1
| barrier() (compiler-level barrier)
| store A = 1
x = load A |
membarrier(CMD_SHARED) |
smp_mb() [1] |
iter. on nohz cpus |
if iter_t->membarrier_exped == 0 |
(skip) |
smp_mb() [2] |
y = load B |
Expect: if x == 1, then y == 1
CPU 0 can observe A == 1, membarrier_exped == 0, and B == 0,
because there is no memory barrier between store to
membarrier_exped and store to A on CPU 1.
What we seem to need on the registration/unregistration side
is store-acquire for registration, and store-release for
unregistration. This pairs with a load of membarrier_exped
that has both acquire and release barriers ([1] and [2] above).
> I'm not seeing how a regular fork() could possibly ever make sense to
> have the membarrier state in the newly forked process. Not that
> "fork()" is really well-defined for within a single thread anyway (it
> actually is as far as Linux is concerned, but not in POSIX, afaik).
>
> So if there is no major reason for it, I would strongly suggest that
> _if_ all this makes sense in the first place, the membarrier thing
> should just be cleared unconditionally both for exec and for
> clone/fork.
That's fine with me!
Thanks,
Mathieu
>
> Linus
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next prev parent reply other threads:[~2017-01-17 2:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-16 19:51 [RFC PATCH] membarrier: handle nohz_full with expedited thread registration Mathieu Desnoyers
2017-01-16 20:15 ` Linus Torvalds
2017-01-16 22:56 ` Mathieu Desnoyers
2017-01-16 23:50 ` Linus Torvalds
2017-01-17 2:09 ` Mathieu Desnoyers [this message]
2017-01-17 3:55 ` Frederic Weisbecker
2017-01-17 20:53 ` Paul E. McKenney
2017-01-18 11:00 ` Peter Zijlstra
2017-01-19 22:01 ` Paul McKenney
2017-01-17 21:56 ` Mathieu Desnoyers
2017-01-17 23:29 ` Steven Rostedt
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=792537721.5599.1484618978163.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=akpm@linux-foundation.org \
--cc=bobby.prani@gmail.com \
--cc=dhowells@redhat.com \
--cc=gnomes@lxorguk.ukuu.org.uk \
--cc=josh@joshtriplett.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mtk.manpages@gmail.com \
--cc=nmiell@comcast.net \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=shuahkh@osg.samsung.com \
--cc=stephen@networkplumber.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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