From: Alan Stern <stern@rowland.harvard.edu>
To: Joel Fernandes <joel@joelfernandes.org>
Cc: "Paul E. McKenney" <paulmck@kernel.org>,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
kernel-team@meta.com, mingo@kernel.org, parri.andrea@gmail.com,
will@kernel.org, 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
Subject: Re: Current LKMM patch disposition
Date: Sat, 11 Feb 2023 11:34:04 -0500 [thread overview]
Message-ID: <Y+fDfMaZ6ix3rxlF@rowland.harvard.edu> (raw)
In-Reply-To: <Y+e5E6YkVw3C9YBk@google.com>
On Sat, Feb 11, 2023 at 03:49:39PM +0000, Joel Fernandes wrote:
> Hi Alan, all,
>
> One thing I noticed: Shouldn't the model have some notion of fences with the
> srcu lock primitive? SRCU implementation in the kernel does an unconditional
> memory barrier on srcu_read_lock() (which it has to do for a number of
> reasons including correctness), but currently both with/without this patch,
> the following returns "Sometimes", instead of "Never". Sorry if this was
> discussed before:
>
> C MP+srcu
>
> (*
> * Result: Sometimes
> *
> * If an srcu_read_unlock() is called between 2 stores, they should propogate
> * in order.
> *)
>
> {}
>
> P0(struct srcu_struct *s, int *x, int *y)
> {
> int r1;
>
> r1 = srcu_read_lock(s);
> WRITE_ONCE(*x, 1);
> srcu_read_unlock(s, r1); // replace with smp_mb() makes Never.
> WRITE_ONCE(*y, 1);
> }
>
> P1(struct srcu_struct *s, int *x, int *y)
> {
> int r1;
> int r2;
>
> r1 = READ_ONCE(*y);
> smp_rmb();
> r2 = READ_ONCE(*x);
> }
>
> exists (1:r1=1 /\ 1:r2=0)
As far as I know, the SRCU API does not guarantee this behavior. The
current implementation behaves this way, but future implementations
might not. Therefore we don't want to put it in the memory model.
> Also, one more general (and likely silly) question about reflexive-transitive closures.
>
> Say you have 2 relations, R1 and R2. Except that R2 is completely empty.
>
> What does (R1; R2)* return?
It returns the identity relation, that is, a relation which links each
event with itself. Remember, R* is defined as linking A to B if there
is a series of R links, of _any_ length (including 0!), going from A to
B. Since there is always a series of length 0 linking A to itself, R*
always contains the identity relation.
> I expect (R1; R2) to be empty, since there does not exist a tail in R1, that
> is a head in R2.
Correct. But for any relation R, R* always contains the identity
relation -- even when R is empty. R+, on the other hand, does not.
That's the difference between R* and R+: In R* the series of links can
be of any length, whereas in R+ there must be at least one link.
In your example, both R2+ and (R1 ; R2)+ would be empty.
> However, that does not appear to be true like in the carry-srcu-data relation
> in Alan's patch. For instance, if I have a simple litmus test with a single
> reader on a single CPU, and an updater on a second CPU, I see that
> carry-srcu-data is a bunch of self-loops on all individual loads and stores
> on all CPUs, including the loads and stores surrounding the updater's
> synchronize_srcu() call, far from being an empty relation!
Yep, that's the identity relation.
Alan
next prev parent reply other threads:[~2023-02-11 16:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-04 0:48 Current LKMM patch disposition Paul E. McKenney
2023-02-04 1:28 ` Alan Stern
2023-02-04 1:49 ` Paul E. McKenney
2023-02-04 14:58 ` Alan Stern
2023-02-04 22:24 ` Paul E. McKenney
2023-02-05 14:10 ` Joel Fernandes
2023-02-06 18:39 ` Alan Stern
2023-02-06 21:22 ` Joel Fernandes
2023-02-11 15:49 ` Joel Fernandes
2023-02-11 16:34 ` Alan Stern [this message]
2023-02-11 17:18 ` Joel Fernandes
2023-02-11 20:19 ` Alan Stern
2023-02-12 0:30 ` Joel Fernandes
2023-02-12 2:59 ` Alan Stern
2023-02-12 3:35 ` Joel Fernandes
2023-02-13 0:54 ` Joel Fernandes
2023-02-13 11:15 ` Andrea Parri
2023-02-14 0:52 ` Joel Fernandes
2023-02-13 16:48 ` Alan Stern
2023-02-14 0:36 ` Joel Fernandes
2023-02-14 1:57 ` Alan Stern
2023-02-14 2:12 ` Joel Fernandes
2023-02-18 6:13 ` Joel Fernandes
2023-02-18 19:21 ` Paul E. McKenney
2023-02-19 3:20 ` Joel Fernandes
2023-02-19 8:09 ` Paul E. McKenney
2023-02-19 2:05 ` Andrea Parri
2023-02-19 2:58 ` Joel Fernandes
2023-02-06 20:18 ` Jonas Oberhauser
2023-02-06 21:23 ` Paul E. McKenney
2023-02-06 20:20 ` Jonas Oberhauser
2023-02-06 21:29 ` 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=Y+fDfMaZ6ix3rxlF@rowland.harvard.edu \
--to=stern@rowland.harvard.edu \
--cc=akiyks@gmail.com \
--cc=boqun.feng@gmail.com \
--cc=dhowells@redhat.com \
--cc=j.alglave@ucl.ac.uk \
--cc=joel@joelfernandes.org \
--cc=kernel-team@meta.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=mingo@kernel.org \
--cc=npiggin@gmail.com \
--cc=parri.andrea@gmail.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--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;
as well as URLs for NNTP newsgroup(s).