lkmm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@kernel.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Jonas Oberhauser <jonas.oberhauser@huaweicloud.com>,
	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,
	dlustig@nvidia.com, joel@joelfernandes.org, urezki@gmail.com,
	quic_neeraju@quicinc.com, frederic@kernel.org,
	linux-kernel@vger.kernel.org, lkmm@lists.linux.dev,
	hernan.poncedeleon@huaweicloud.com
Subject: Re: [RFC] tools/memory-model: Rule out OOTA
Date: Wed, 23 Jul 2025 12:57:13 -0700	[thread overview]
Message-ID: <9963f6a6-9da9-4120-b1fe-e4a1df9edda1@paulmck-laptop> (raw)
In-Reply-To: <b9c250b2-e4c0-4e8f-b37c-b51d93b980f0@rowland.harvard.edu>

On Wed, Jul 23, 2025 at 03:25:13PM -0400, Alan Stern wrote:
> On Tue, Jul 22, 2025 at 05:43:16PM -0700, Paul E. McKenney wrote:
> >     Also, C-JO-OOTA-7.litmus includes a "*r2 = a" statement that makes herd7
> >     very unhappy.  On the other hand, initializing registers to the address
> >     of a variable is straight forward, as shown in the resulting litmus test.
> 
> ...
> 
> > diff --git a/manual/oota/C-JO-OOTA-7.litmus b/manual/oota/C-JO-OOTA-7.litmus
> > new file mode 100644
> > index 00000000..31c0b8ae
> > --- /dev/null
> > +++ b/manual/oota/C-JO-OOTA-7.litmus
> > @@ -0,0 +1,47 @@
> > +C C-JO-OOTA-7
> > +
> > +(*
> > + * Result: Never
> > + *
> > + * But LKMM finds the all-ones result, due to OOTA on r2.
> > + *
> > + * https://lore.kernel.org/all/1147ad3e-e3ad-4fa1-9a63-772ba136ea9a@huaweicloud.com/
> > + *)
> > +
> > +{
> > +	0:r2=a;
> > +	1:r2=b;
> > +}
> 
> In this litmus test a and b are never assigned any values, so they
> always contain 0.
> 
> > +
> > +P0(int *a, int *b, int *x, int *y)
> > +{
> > +	int r1;
> > +	int r2;
> > +
> > +	r1 = READ_ONCE(*x);
> > +	smp_rmb();
> > +	if (r1 == 1) {
> > +		r2 = READ_ONCE(*a);
> 
> If this executes then r2 now contains 0.
> 
> > +	}
> > +	*r2 = a;
> 
> And so what is supposed to happen here?  No wonder herd7 is unhappy!

Nothing good, I will admit!  Good eyes, and thank you!

> > +	smp_wmb();
> > +	WRITE_ONCE(*y, 1);
> > +}
> > +
> > +P1(int *a, int *b, int *x, int *y)
> > +{
> > +	int r1;
> > +	int r2;
> > +
> > +	r1 = READ_ONCE(*y);
> > +	smp_rmb();
> > +	if (r1 == 1) {
> > +		r2 = READ_ONCE(*b);
> > +	}
> > +	*r2 = b;
> 
> Same here.
> 
> > +	smp_wmb();
> > +	WRITE_ONCE(*x, 1);
> > +}
> > +
> > +locations [0:r2;1:r2]
> > +exists (0:r1=1 /\ 1:r1=1)

Yes, I did misinterpret Jonas's initialization advice, which reads
as follows:  "unless you know how to initialize *a and *b to valid
addresses, you may need to add something like `if (r2 == 0) r2 = a`
to run this in herd7".

Given that there are two instances of r2, there are a number of
possible combinations of initialization.  I picked the one shown
in the patch below, and got this:

$ herd7 -conf linux-kernel.cfg ~/paper/scalability/LWNLinuxMM/litmus/manual/oota/C-JO-OOTA-7.litmus
Test C-JO-OOTA-7 Allowed
States 3
0:r1=0; 0:r2=a; 1:r1=0; 1:r2=b;
0:r1=0; 0:r2=a; 1:r1=1; 1:r2=b;
0:r1=1; 0:r2=a; 1:r1=0; 1:r2=b;
No
Witnesses
Positive: 0 Negative: 3
Flag mixed-accesses
Condition exists (0:r1=1 /\ 1:r1=1)
Observation C-JO-OOTA-7 Never 0 3
Time C-JO-OOTA-7 0.01
Hash=d9bb35335e45b31b1a39bab88eca837c

I get something very similar if I cross-initialize them, that is
a=b;b=a.

Thoughts?

							Thanx, Paul

------------------------------------------------------------------------

diff --git a/manual/oota/C-JO-OOTA-7.litmus b/manual/oota/C-JO-OOTA-7.litmus
index 31c0b8ae..d7fe0f94 100644
--- a/manual/oota/C-JO-OOTA-7.litmus
+++ b/manual/oota/C-JO-OOTA-7.litmus
@@ -11,6 +11,8 @@ C C-JO-OOTA-7
 {
 	0:r2=a;
 	1:r2=b;
+	a=a;
+	b=b;
 }
 
 P0(int *a, int *b, int *x, int *y)

      reply	other threads:[~2025-07-23 19:57 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06 21:40 [RFC] tools/memory-model: Rule out OOTA Jonas Oberhauser
2025-01-07 10:06 ` Peter Zijlstra
2025-01-07 11:02   ` Jonas Oberhauser
2025-01-07 15:46 ` Jonas Oberhauser
2025-01-07 16:09 ` Alan Stern
2025-01-07 18:47   ` Paul E. McKenney
2025-01-08 17:39     ` Jonas Oberhauser
2025-01-08 18:09       ` Paul E. McKenney
2025-01-08 19:17         ` Jonas Oberhauser
2025-01-09 17:54           ` Paul E. McKenney
2025-01-09 18:35             ` Jonas Oberhauser
2025-01-10 14:54               ` Paul E. McKenney
2025-01-10 16:21                 ` Jonas Oberhauser
2025-01-13 22:04                   ` Paul E. McKenney
2025-01-16 18:40                     ` Paul E. McKenney
2025-01-16 19:13                       ` Jonas Oberhauser
2025-01-16 19:31                         ` Paul E. McKenney
2025-01-16 20:21                           ` Jonas Oberhauser
2025-01-16 19:28                       ` Jonas Oberhauser
2025-01-16 19:39                         ` Paul E. McKenney
2025-01-17 12:08                           ` Jonas Oberhauser
2025-01-16 19:08                     ` Jonas Oberhauser
2025-01-16 23:02                       ` Alan Stern
2025-01-17  8:34                         ` Hernan Ponce de Leon
2025-01-17 11:29                         ` Jonas Oberhauser
2025-01-17 20:01                           ` Alan Stern
2025-01-21 10:36                             ` Jonas Oberhauser
2025-01-21 16:39                               ` Alan Stern
2025-01-22  3:46                                 ` Jonas Oberhauser
2025-01-22 19:11                                   ` Alan Stern
2025-01-17 15:52                         ` Alan Stern
2025-01-17 16:45                           ` Jonas Oberhauser
2025-01-17 19:02                             ` Alan Stern
2025-01-09 20:37             ` Peter Zijlstra
2025-01-09 21:13               ` Paul E. McKenney
2025-01-08 17:33   ` Jonas Oberhauser
2025-01-08 18:47     ` Alan Stern
2025-01-08 19:22       ` Jonas Oberhauser
2025-01-09 16:17         ` Alan Stern
2025-01-09 16:44           ` Jonas Oberhauser
2025-01-09 19:27             ` Alan Stern
2025-01-09 20:09               ` Jonas Oberhauser
2025-01-10  3:12                 ` Alan Stern
2025-01-10 12:21                   ` Jonas Oberhauser
2025-01-10 21:51                     ` Alan Stern
2025-01-11 12:46                       ` Jonas Oberhauser
2025-01-11 21:19                         ` Alan Stern
2025-01-12 15:55                           ` Jonas Oberhauser
2025-01-13 19:43                             ` Alan Stern
2025-07-23  0:43 ` Paul E. McKenney
2025-07-23  7:26   ` Hernan Ponce de Leon
2025-07-23 16:39     ` Paul E. McKenney
2025-07-24 14:14       ` Paul E. McKenney
2025-07-25  5:23         ` Hernan Ponce de Leon
2025-07-29 20:34           ` Paul E. McKenney
2025-07-23 17:13   ` Alan Stern
2025-07-23 17:27     ` Paul E. McKenney
2025-07-23 19:25   ` Alan Stern
2025-07-23 19:57     ` Paul E. McKenney [this message]

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=9963f6a6-9da9-4120-b1fe-e4a1df9edda1@paulmck-laptop \
    --to=paulmck@kernel.org \
    --cc=akiyks@gmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=dlustig@nvidia.com \
    --cc=frederic@kernel.org \
    --cc=hernan.poncedeleon@huaweicloud.com \
    --cc=j.alglave@ucl.ac.uk \
    --cc=joel@joelfernandes.org \
    --cc=jonas.oberhauser@huaweicloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkmm@lists.linux.dev \
    --cc=luc.maranget@inria.fr \
    --cc=npiggin@gmail.com \
    --cc=parri.andrea@gmail.com \
    --cc=peterz@infradead.org \
    --cc=quic_neeraju@quicinc.com \
    --cc=stern@rowland.harvard.edu \
    --cc=urezki@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).