From: "Paul E. McKenney" <paulmck@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: "Björn Töpel" <bjorn.topel@gmail.com>, bpf <bpf@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
parri.andrea@gmail.com, "Will Deacon" <will@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
boqun.feng@gmail.com, npiggin@gmail.com, dhowells@redhat.com,
j.alglave@ucl.ac.uk, luc.maranget@inria.fr, akiyks@gmail.com,
dlustig@nvidia.com, joel@joelfernandes.org,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Karlsson, Magnus" <magnus.karlsson@intel.com>
Subject: Re: XDP socket rings, and LKMM litmus tests
Date: Thu, 4 Mar 2021 14:05:29 -0800 [thread overview]
Message-ID: <20210304220529.GW2696@paulmck-ThinkPad-P72> (raw)
In-Reply-To: <20210304212753.GB14408@rowland.harvard.edu>
On Thu, Mar 04, 2021 at 04:27:53PM -0500, Alan Stern wrote:
> On Thu, Mar 04, 2021 at 11:05:15AM -0800, Paul E. McKenney wrote:
> > On Thu, Mar 04, 2021 at 10:35:24AM -0500, Alan Stern wrote:
> > > On Wed, Mar 03, 2021 at 09:04:07PM -0800, Paul E. McKenney wrote:
> > > > On Wed, Mar 03, 2021 at 10:21:01PM -0500, Alan Stern wrote:
> > > > > On Wed, Mar 03, 2021 at 02:03:48PM -0800, Paul E. McKenney wrote:
> > > > > > On Wed, Mar 03, 2021 at 03:22:46PM -0500, Alan Stern wrote:
> > >
> > > > > > > > And I cannot immediately think of a situation where
> > > > > > > > this approach would break that would not result in a data race being
> > > > > > > > flagged. Or is this yet another failure of my imagination?
> > > > > > >
> > > > > > > By definition, an access to a local variable cannot participate in a
> > > > > > > data race because all such accesses are confined to a single thread.
> > > > > >
> > > > > > True, but its value might have come from a load from a shared variable.
> > > > >
> > > > > Then that load could have participated in a data race. But the store to
> > > > > the local variable cannot.
> > > >
> > > > Agreed. My thought was that if the ordering from the initial (non-local)
> > > > load mattered, then that initial load must have participated in a
> > > > data race. Is that true, or am I failing to perceive some corner case?
> > >
> > > Ordering can matter even when no data race is involved. Just think
> > > about how much of the memory model is concerned with ordering of
> > > marked accesses, which don't participate in data races unless there is
> > > a conflicting plain access somewhere.
> >
> > Fair point. Should I have instead said "then that initial load must
> > have run concurrently with a store to that same variable"?
>
> I'm losing track of the point you were originally trying to make.
>
> Does ordering matter when there are no conflicting accesses? Sure.
> Consider this:
>
> A: r1 = READ_ONCE(x);
> B: WRITE_ONCE(y, r1);
> smp_wmb();
> C: WRITE_ONCE(z, 1);
>
> Even if there are no other accesses to y at all (let alone any
> conflicting ones), the mere existence of B forces A to be ordered before
> C, and this is easily detectable by a litmus test.
Given that herd7 treats all local variables as registers (including
forbidding taking their addresses), and given that we are not thinking of
treating local-variable accesses as if they were marked, this is likely
all moot.
But just in case...
I was trying to figure out if there was a litmus test of the following
form where it might make a difference if local-variable accesses were
treated as if they were marked. So is there something like this:
r1 = x;
if (r1)
WRITE_ONCE(y, 1);
where implicitly treating the accesses to r1 as marked would make a
difference. I was thinking that any such example would have to result
in LKMM flagging the load from x as a data race. However, your example
inserting the smp_wmb() does shed some doubt on that theory.
This of course is moot unless we come back to treating local-variable
accesses as if they were marked.
Thanx, Paul
next prev parent reply other threads:[~2021-03-04 22:06 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-02 18:46 XDP socket rings, and LKMM litmus tests Björn Töpel
2021-03-02 19:57 ` Paul E. McKenney
2021-03-02 20:04 ` Paul E. McKenney
2021-03-02 20:37 ` Björn Töpel
2021-03-02 20:24 ` Björn Töpel
2021-03-02 20:41 ` Paul E. McKenney
2021-03-02 20:51 ` Björn Töpel
2021-03-02 21:14 ` Alan Stern
2021-03-02 23:50 ` Paul E. McKenney
2021-03-03 6:37 ` maranget
2021-03-03 16:54 ` Paul E. McKenney
2021-03-03 17:12 ` Alan Stern
2021-03-03 17:37 ` maranget
2021-03-03 17:39 ` maranget
2021-03-03 21:56 ` Paul E. McKenney
2021-03-03 19:40 ` Alan Stern
2021-03-03 17:40 ` Paul E. McKenney
2021-03-03 20:22 ` Alan Stern
2021-03-03 22:03 ` Paul E. McKenney
2021-03-04 3:21 ` Alan Stern
2021-03-04 5:04 ` Paul E. McKenney
2021-03-04 15:35 ` Alan Stern
2021-03-04 19:05 ` Paul E. McKenney
2021-03-04 21:27 ` Alan Stern
2021-03-04 22:05 ` Paul E. McKenney [this message]
2021-03-04 1:26 ` Boqun Feng
2021-03-04 3:13 ` Alan Stern
2021-03-04 6:33 ` Boqun Feng
2021-03-04 16:11 ` Alan Stern
2021-03-05 1:12 ` Boqun Feng
2021-03-05 16:15 ` Alan Stern
2021-03-04 15:44 ` maranget
2021-03-04 19:07 ` Paul E. McKenney
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=20210304220529.GW2696@paulmck-ThinkPad-P72 \
--to=paulmck@kernel.org \
--cc=akiyks@gmail.com \
--cc=bjorn.topel@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=dlustig@nvidia.com \
--cc=j.alglave@ucl.ac.uk \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=magnus.karlsson@intel.com \
--cc=npiggin@gmail.com \
--cc=parri.andrea@gmail.com \
--cc=peterz@infradead.org \
--cc=stern@rowland.harvard.edu \
--cc=toke@redhat.com \
--cc=will@kernel.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