From: Daniel Lustig <dlustig@nvidia.com>
To: Andrea Parri <andrea.parri@amarulasolutions.com>,
Peter Zijlstra <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
Will Deacon <will.deacon@arm.com>,
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>,
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: Mon, 25 Jun 2018 08:44:14 -0700 [thread overview]
Message-ID: <bad7783b-9510-0049-b10a-a0d7f7273b57@nvidia.com> (raw)
In-Reply-To: <20180625145611.GA16333@andrea>
On 6/25/2018 7:56 AM, Andrea Parri wrote:
> On Mon, Jun 25, 2018 at 04:18:30PM +0200, Peter Zijlstra wrote:
>> On Mon, Jun 25, 2018 at 03:16:43PM +0200, Andrea Parri wrote:
>>>>> A concrete example being the store-buffering pattern reported in [1].
>>>>
>>>> Well, that example only needs a store->load barrier. It so happens
>>>> smp_mb() is the only one actually doing that, but imagine we had a
>>>> weaker barrier that did just that, one that did not imply the full
>>>> transitivity smp_mb() does.
>>>>
>>>> Then the example from [1] could use that weaker thing.
>>>
>>> Absolutely (and that would be "fence w,r" on RISC-V, IIUC).
>>
>> Ah cute. What is the transitivity model of those "fence" instructions? I
>> see their smp_mb() is "fence rw,rw" and smp_mb() must be RSsc. Otoh
>> their smp_wmb() is "fence w,w" which is only only required to be RCpc.
>>
>> So what does RISC-V do for "w,w" and "w,r" like things?
>
> I'd defer to Daniel (in Cc:) for this ;-) I simply checked the SB pattern
> plus w,r fences against the following models:
>
> http://www.cl.cam.ac.uk/~sf502/regressions/rmem/
> http://moscova.inria.fr/~maranget/cats7/riscv/
>
First off, the latest RISC-V spec is here, in case anyone hasn't seen it:
https://github.com/riscv/riscv-isa-manual. It's all public now,
fortunately. There's a PDF link at the bottom of that page too. The
spec now has proposed Linux mappings (not all of which have actually made
it upstream...) in Appendix A.5 as well. We'd welcome general feedback
on those.
Now to the question above:
RISC-V is (other-)multi-copy-atomic, so I don't think transitivity
should be an issue here.
We do have a "fence w,r", but we decided to warn against actually using
it for a few reasons: 1) lack of known common use cases :), 2) IIRC
there was some corner case discrepancy between the axiomatic and
operational models if we allowed it, and 3) in practice, it's already
both expensive enough and obscure enough that many or most
implementations will simply just treat it as "fence rw,rw" anyway.
So, in theory, "fence w,r" should be enough to prevent SB-like patterns.
It's just not yet clear that it's a big enough win that it's worth
creating a new fence macro for it, or pulling the current RISC-V
recommendation against its use. What do you all think?
Are there other known use cases where you really do want a "fence w,r"
that's intentionally not also something stronger? How common would the
pattern be?
Dan
next prev parent reply other threads:[~2018-06-25 15:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-25 9:17 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 [this message]
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
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=bad7783b-9510-0049-b10a-a0d7f7273b57@nvidia.com \
--to=dlustig@nvidia.com \
--cc=akiyks@gmail.com \
--cc=andrea.parri@amarulasolutions.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=dhowells@redhat.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
all inboxes | Powered by JetHome®