From: Boqun Feng <boqun.feng@gmail.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: stern@rowland.harvard.edu, parri.andrea@gmail.com,
will@kernel.org, peterz@infradead.org, npiggin@gmail.com,
dhowells@redhat.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr,
akiyks@gmail.com, dlustig@nvidia.com, joel@joelfernandes.org,
linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: Re: "Verifying and Optimizing Compact NUMA-Aware Locks on Weak Memory Models"
Date: Fri, 26 Aug 2022 09:21:03 -0700 [thread overview]
Message-ID: <Ywjy71aazWmNUHbJ@boqun-archlinux> (raw)
In-Reply-To: <20220826124812.GA3007435@paulmck-ThinkPad-P17-Gen-1>
On Fri, Aug 26, 2022 at 05:48:12AM -0700, Paul E. McKenney wrote:
> Hello!
>
> I have not yet done more than glance at this one, but figured I should
> send it along sooner rather than later.
>
> "Verifying and Optimizing Compact NUMA-Aware Locks on Weak
> Memory Models", Antonio Paolillo, Hernán Ponce-de-León, Thomas
> Haas, Diogo Behrens, Rafael Chehab, Ming Fu, and Roland Meyer.
> https://arxiv.org/abs/2111.15240
>
> The claim is that the queued spinlocks implementation with CNA violates
> LKMM but actually works on all architectures having a formal hardware
> memory model.
>
Translate one of their litmus test into a runnable one (there is a typo
in it):
C queued-spin-lock
(*
* P0 is lock-release
* P1 is xchg_tail()
* P2 is lock-acquire
*)
{}
P0(int *x, atomic_t *l)
{
WRITE_ONCE(*x, 1);
atomic_set_release(l, 1);
}
P1(int *x, atomic_t *l)
{
int val;
int new;
int old;
val = atomic_read(l);
new = val + 2;
old = atomic_cmpxchg_relaxed(l, val, new);
}
P2(int *x, atomic_t *l)
{
int r0 = atomic_read_acquire(l);
int r1 = READ_ONCE(*x);
}
exists (2:r0=3 /\ 2:r1=0)
According to LKMM, the exist-clause could be triggered because:
po-rel; coe: rfe; acq-po
is not happen-before in LKMM. Alan actually explain why at a response to
a GitHub issue:
https://github.com/paulmckrcu/litmus/issues/11#issuecomment-1115235860
(Paste Alan's reply)
"""
As for why the LKMM doesn't require ordering for this test... I do not
believe this is related to 2+2W. Think instead in terms of the LKMM's
operational model:
The store-release in P0 means that the x=1 write will propagate
to each CPU before the y=1 write does.
Since y=3 at the end, we know that y=1 (and hence x=1 too)
propagates to P1 before the addition occurs. And we know that
y=3 propagates to P2 before the load-acquire executes.
But we _don't_ know that either y=1 or x=1 propagates to P2
before y=3 does! If the store in P1 were a store-release then
this would have to be true (as you saw in your tests), but it
isn't.
In other words, the litmus test could execute with the following
temporal ordering:
P0 P1 P2
---------- --------- ----------
Write x=1
Write y=1
[x=1 and y=1 propagate to P1]
Read y=1
Write y=3
[y=3 propagates to P2]
Read y=3
Read x=0
[x=1 and y=1 propagate to P2]
(Note that when y=1 propagates to P2, it doesn't do anything because it
won't overwrite the coherence-later store y=3.)
It may be true that none of the architectures supported by Linux will
allow this outcome for the test (although I suspect that the PPC-weird
version _would_ be allowed if you fixed it). At any rate, disallowing
this result in the memory model would probably require more effort than
would be worthwhile.
Alan
"""
The question is that whether we "fix" LKMM because of this, or we
mention explicitly this is something "unsupported" by LKMM yet?
Regards,
Boqun
> Thoughts?
>
> Thanx, Paul
next prev parent reply other threads:[~2022-08-26 16:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 12:48 "Verifying and Optimizing Compact NUMA-Aware Locks on Weak Memory Models" Paul E. McKenney
2022-08-26 16:21 ` Boqun Feng [this message]
2022-08-26 16:23 ` Peter Zijlstra
2022-08-26 17:10 ` Alan Stern
2022-08-26 20:42 ` Paul E. McKenney
2022-08-27 16:00 ` Alan Stern
2022-08-27 17:04 ` Paul E. McKenney
2022-09-13 11:24 ` Will Deacon
2022-09-13 12:21 ` Dan Lustig
2022-09-16 8:18 ` Will Deacon
2022-08-26 23:47 ` Peter Zijlstra
2022-08-27 16:05 ` Alan Stern
2022-08-27 16:44 ` Boqun Feng
2022-08-29 2:15 ` Andrea Parri
2022-09-09 11:45 ` Jonas Oberhauser
2022-09-10 12:11 ` Hernan Luis Ponce de Leon
2022-09-10 15:03 ` Alan Stern
2022-09-10 20:41 ` Hernan Luis Ponce de Leon
2022-09-11 10:20 ` Joel Fernandes
2022-09-12 10:13 ` Jonas Oberhauser
2022-09-12 11:10 ` Hernan Luis Ponce de Leon
2022-09-14 14:41 ` Alan Stern
2022-09-12 12:01 ` Alan Stern
2022-09-11 14:53 ` Andrea Parri
2022-09-12 10:46 ` Jonas Oberhauser
2022-09-12 12:02 ` Alan Stern
2022-08-29 2:33 ` Andrea Parri
2022-08-29 12:25 ` 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=Ywjy71aazWmNUHbJ@boqun-archlinux \
--to=boqun.feng@gmail.com \
--cc=akiyks@gmail.com \
--cc=dhowells@redhat.com \
--cc=dlustig@nvidia.com \
--cc=j.alglave@ucl.ac.uk \
--cc=joel@joelfernandes.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luc.maranget@inria.fr \
--cc=npiggin@gmail.com \
--cc=parri.andrea@gmail.com \
--cc=paulmck@kernel.org \
--cc=peterz@infradead.org \
--cc=stern@rowland.harvard.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;
as well as URLs for NNTP newsgroup(s).