[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <b0cc2cd8-e246-40d1-b091-f40a74b31f61@app.fastmail.com>
Date: Thu, 10 Aug 2023 08:51:34 +0200
From: "Arnd Bergmann" <arnd@...db.de>
To: "Leonardo Bras" <leobras@...hat.com>,
"Will Deacon" <will@...nel.org>,
"Peter Zijlstra" <peterz@...radead.org>,
"Boqun Feng" <boqun.feng@...il.com>,
"Mark Rutland" <mark.rutland@....com>,
"Paul Walmsley" <paul.walmsley@...ive.com>,
"Palmer Dabbelt" <palmer@...belt.com>,
"Albert Ou" <aou@...s.berkeley.edu>,
"Andrea Parri" <parri.andrea@...il.com>,
"Andrzej Hajda" <andrzej.hajda@...el.com>,
"Palmer Dabbelt" <palmer@...osinc.com>, guoren <guoren@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-riscv@...ts.infradead.org
Subject: Re: [RFC PATCH v5 5/5] riscv/cmpxchg: Implement xchg for variables of size 1
and 2
On Thu, Aug 10, 2023, at 06:03, Leonardo Bras wrote:
> xchg for variables of size 1-byte and 2-bytes is not yet available for
> riscv, even though its present in other architectures such as arm64 and
> x86. This could lead to not being able to implement some locking mechanisms
> or requiring some rework to make it work properly.
>
> Implement 1-byte and 2-bytes xchg in order to achieve parity with other
> architectures.
>
> Signed-off-by: Leonardo Bras <leobras@...hat.com>
Parity with other architectures by itself is not a reason to do this,
in particular the other architectures you listed have the instructions
in hardware while riscv does not.
Emulating the small xchg() through cmpxchg() is particularly tricky
since it's easy to run into a case where this does not guarantee
forward progress. This is also something that almost no architecture
specific code relies on (generic qspinlock being a notable exception).
I would recommend just dropping this patch from the series, at least
until there is a need for it.
Arnd
Powered by blists - more mailing lists