From: Peter Zijlstra <peterz@infradead.org>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
linux-doc@vger.kernel.org,
"Paul E . McKenney " <paulmck@kernel.org>,
Dan Lustig <dlustig@nvidia.com>, Will Deacon <will@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Peter Anvin <hpa@zytor.com>,
Andrea Parri <parri.andrea@gmail.com>,
Ingo Molnar <mingo@kernel.org>,
Vince Weaver <vincent.weaver@maine.edu>,
Thomas Gleixner <tglx@linutronix.de>,
Jiri Olsa <jolsa@redhat.com>,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Stephane Eranian <eranian@google.com>,
palmer@dabbelt.com, paul.walmsley@sifive.com, mpe@ellerman.id.au,
Jonathan Corbet <corbet@lwn.net>,
Alan Stern <stern@rowland.harvard.edu>
Subject: Re: [RFC v2 3/3] tools/memory-model: litmus: Add two tests for unlock(A)+lock(B) ordering
Date: Tue, 26 Oct 2021 09:01:00 +0200 [thread overview]
Message-ID: <YXenrNeS+IaSDwvU@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20211025145416.698183-4-boqun.feng@gmail.com>
On Mon, Oct 25, 2021 at 10:54:16PM +0800, Boqun Feng wrote:
> diff --git a/tools/memory-model/litmus-tests/LB+unlocklockonceonce+poacquireonce.litmus b/tools/memory-model/litmus-tests/LB+unlocklockonceonce+poacquireonce.litmus
> new file mode 100644
> index 000000000000..955b9c7cdc7f
> --- /dev/null
> +++ b/tools/memory-model/litmus-tests/LB+unlocklockonceonce+poacquireonce.litmus
> @@ -0,0 +1,33 @@
> +C LB+unlocklockonceonce+poacquireonce
> +
> +(*
> + * Result: Never
> + *
> + * If two locked critical sections execute on the same CPU, all accesses
> + * in the first must execute before any accesses in the second, even if
> + * the critical sections are protected by different locks.
One small nit; the above "all accesses" reads as if:
spin_lock(s);
WRITE_ONCE(*x, 1);
spin_unlock(s);
spin_lock(t);
r1 = READ_ONCE(*y);
spin_unlock(t);
would also work, except of course that's the one reorder allowed by TSO.
> + *)
> +
> +{}
> +
> +P0(spinlock_t *s, spinlock_t *t, int *x, int *y)
> +{
> + int r1;
> +
> + spin_lock(s);
> + r1 = READ_ONCE(*x);
> + spin_unlock(s);
> + spin_lock(t);
> + WRITE_ONCE(*y, 1);
> + spin_unlock(t);
> +}
> +
> +P1(int *x, int *y)
> +{
> + int r2;
> +
> + r2 = smp_load_acquire(y);
> + WRITE_ONCE(*x, 1);
> +}
> +
> +exists (0:r1=1 /\ 1:r2=1)
next prev parent reply other threads:[~2021-10-26 7:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 14:54 [RFC v2 0/3] memory model: Make unlock(A)+lock(B) on the same CPU RCtso Boqun Feng
2021-10-25 14:54 ` [RFC v2 1/3] tools/memory-model: Provide extra ordering for unlock+lock pair on the same CPU Boqun Feng
2021-10-25 14:54 ` [RFC v2 2/3] tools/memory-model: doc: Describe the requirement of the litmus-tests directory Boqun Feng
2021-10-25 14:54 ` [RFC v2 3/3] tools/memory-model: litmus: Add two tests for unlock(A)+lock(B) ordering Boqun Feng
2021-10-26 7:01 ` Peter Zijlstra [this message]
2021-10-28 19:11 ` Paul E. McKenney
2021-10-28 23:51 ` Boqun Feng
2021-10-29 14:34 ` Alan Stern
2021-10-29 15:01 ` Paul E. McKenney
2021-10-26 6:59 ` [RFC v2 0/3] memory model: Make unlock(A)+lock(B) on the same CPU RCtso Peter Zijlstra
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=YXenrNeS+IaSDwvU@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=boqun.feng@gmail.com \
--cc=corbet@lwn.net \
--cc=dlustig@nvidia.com \
--cc=eranian@google.com \
--cc=hpa@zytor.com \
--cc=jolsa@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=palmer@dabbelt.com \
--cc=parri.andrea@gmail.com \
--cc=paul.walmsley@sifive.com \
--cc=paulmck@kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=vincent.weaver@maine.edu \
--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