[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wiXJygbW+_1BdSX6M8j6z4w8gRSHVcaD5saihaNJApnoQ@mail.gmail.com>
Date: Wed, 8 Sep 2021 09:08:33 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Alan Stern <stern@...land.harvard.edu>
Cc: Peter Zijlstra <peterz@...radead.org>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Anvin <hpa@...or.com>,
Andrea Parri <parri.andrea@...il.com>,
Ingo Molnar <mingo@...nel.org>,
"Paul E. McKenney" <paulmck@...nel.org>,
Vince Weaver <vincent.weaver@...ne.edu>,
Thomas Gleixner <tglx@...utronix.de>,
Jiri Olsa <jolsa@...hat.com>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Stephane Eranian <eranian@...gle.com>,
Will Deacon <will@...nel.org>,
linux-tip-commits@...r.kernel.org
Subject: Re: [tip:locking/core] tools/memory-model: Add extra ordering for
locks and remove it for ordinary release/acquire
On Wed, Sep 8, 2021 at 7:42 AM Alan Stern <stern@...land.harvard.edu> wrote:
>
> there is no reason _in theory_ why a CPU shouldn't reorder and interleave
> the operations to get:
I agree about the theory part.
But I think the LKMM should be the strongest ordering that is reasonable.
And it should take common architecture behavior into account.
IOW, if there is some rare architecture where the above can happen,
but no common sane one allows it in practice, we should strive to make
the LKMM the _stronger_ one.
We sure as hell shouldn't say "RISC-V is potentially very weakly
ordered, so we'll allow that weak ordering".
Because overly weak ordering only causes problems for others. And the
performance arguments for it have historically been garbage anyway.
See the pain powerpc goes through because of bad ordering (and even
more so alpha), and see how arm actually strengthened their ordering
to make everybody happier.
So if this is purely a RISC-V thing, then I think it's entirely reasonable to
spin_unlock(&r);
spin_lock(&s);
cannot be reordered.
Strict specifications are not a bad thing, and weak memory ordering is
not inherently good.
Linus
Powered by blists - more mailing lists