From: Jisheng Zhang <jszhang@kernel.org>
To: Conor Dooley <conor@kernel.org>
Cc: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Will Deacon" <will@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Gary Guo" <gary@garyguo.net>,
"Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Chao-ying Fu" <chao-ying.fu@globalfoundries.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
torvalds@linux-foundation.org, olof@lixom.net,
aleksa.paunovic@htecgroup.com, arikalo@gmail.com,
"Boqun Feng" <boqun@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Luke Nelson" <luke.r.nels@gmail.com>,
"Xi Wang" <xi.wang@gmail.com>, "Björn Töpel" <bjorn@kernel.org>,
"Pu Lehui" <pulehui@huawei.com>,
"Puranjay Mohan" <puranjay@kernel.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Oleg Nesterov" <oleg@redhat.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, "Jonathan Corbet" <corbet@lwn.net>,
"Charlie Jenkins" <thecharlesjenkins@gmail.com>,
"Nam Cao" <namcao@linutronix.de>,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v6 2/6] riscv: build kernel atomics from LR/SC when Zaamo is disabled
Date: Wed, 11 Nov 2026 12:18:36 +0800 [thread overview]
Message-ID: <avPsnAlbfEsNa5zq@xhacker> (raw)
In-Reply-To: <20261110-revivable-saint-9bcfaa2fd0e7@spud>
On Tue, Nov 10, 2026 at 07:02:48PM +0000, Conor Dooley wrote:
> On Tue, Nov 10, 2026 at 03:20:59PM +0200, Vladimir Kondratiev wrote:
> > The A extension is Zaamo plus Zalrsc. On some CPUs Zaamo is present
> > only formally. MIPS P8700 traps every AMO instruction into M-mode and
> > emulates it there, so the extension is supported but very slow. A
> > typical uncontended atomic increment costs:
> >
> > native AMO 2..5 cycles
> > LR/SC, private L1 reservation monitor 6..12 cycles
> > LR/SC, PoC (L2) reservation monitor about 40 cycles
> > AMO emulated by an M-mode trap about 600 cycles
> >
> > The last two were measured on the eyeq7h hardware. On such a CPU the
> > kernel must use LR/SC for every atomic.
> >
> > Add RISCV_ISA_ZAAMO, default y. The default keeps "a" in -march and
> > the generated code unchanged. When it is disabled, -march carries
> > _zalrsc instead of "a", and atomic_*, bitops, xchg, futex and the
> > early boot code use LR/SC loops. The sequence is chosen with the
> > preprocessor, on CONFIG_RISCV_ISA_ZAAMO like the other ISA options in
> > the headers, because the assembler rejects AMO mnemonics once -march
> > lacks Zaamo. A kernel built this way runs on any hart that implements
> > A; it just does not use AMO. It is therefore a plain option, not a
> > NONPORTABLE one, and the hart keeps advertising "a" to userspace,
> > which is true.
> >
> > The LR/SC loops follow the ordering convention of the existing ones
> > in cmpxchg.h, from commit 5ce6c1f3535f ("riscv/atomic: Strengthen
> > implementations with fences") and commit 1d84afaf0252 ("riscv: Fix
> > fully ordered LR/SC xchg[8|16]() implementations"): a fully ordered
> > operation is lr, sc.rl and a trailing fence rw,rw; acquire is lr.aq
> > with a plain sc; release is a plain lr with sc.rl. The futex loop is
> > bounded to 128 retries and returns -EAGAIN after that, as arm64 does,
> > because userspace can keep the word changing from another thread and
> > futex_wake_op() retries on -EAGAIN anyway.
> >
> > Zabha, Zacas and the ssamoswap instruction of Zicfiss are AMO
> > instructions, so RISCV_ISA_ZABHA, RISCV_ISA_ZACAS and RISCV_USER_CFI
> > depend on RISCV_ISA_ZAAMO. The riscv64imac Rust target emits AMO too,
> > so RUSTC_SUPPORTS_RISCV depends on it as well.
> >
> > The choice is made at compile time rather than with alternatives.
> > Nearly every CPU has a native A extension, and an alternative would
> > inflate all those kernels with the nops needed to pad one AMO to the
> > size of an LR/SC loop, at every atomic site, for the benefit of a few.
> >
> > Turning Zaamo off needs a compiler that accepts _zaamo and _zalrsc in
> > -march. GCC 15.1 is the first release that does.
> > TOOLCHAIN_HAS_ZALRSC_ZAAMO checks for it; with an older compiler the
> > option stays at y.
> >
> > Three sets of extensions provide every atomic Linux needs. "a" is what
> > the kernel supports today. Zalrsc plus Ziccrse is what this patch adds:
> > every atomic is a constrained LR/SC loop, and Ziccrse is the
> > forward-progress guarantee for such loops. Zaamo plus Zacas would do
> > as well, with CAS loops in place of LR/SC as on x86, and is left for
> > whoever has such hardware.
> >
> > Suggested-by: Chao-ying Fu <chao-ying.fu@globalfoundries.com>
> > Nacked-by: Conor Dooley <conor.dooley@microchip.com>
> > Link: https://lore.kernel.org/linux-riscv/20261106-smock-headband-d6a7d568c228@spud/
>
> I had a quick glance at this revision, and I think you've at least tried
> to resolve the things I was pointing out. Did I miss something, or why
> have you kept the NAK after having resolved the things that I was
> objecting to?
>
I searched the maillist for this errata, or workaround or downgrading 'A'
or anything else it's named, found something interesting:
IIUC, Paul has rejected the series, at least call for "hold off on merging them"
see
https://lore.kernel.org/linux-riscv/8afa0702-4d30-86e2-5afb-a7c113a92dec@kernel.org/
and
https://lore.kernel.org/linux-riscv/6201870b-b50d-f6e2-814b-7a1fdbf064db@kernel.org/
But I'm not sure why the same series is still continuously sent out but
in different titles. I think this series can be ignored until riscv
maintainers agree to downgrade the 'A' to subset of 'A', I.E zalrsc
WARNING: multiple messages have this Message-ID (diff)
From: Jisheng Zhang <jszhang@kernel.org>
To: Conor Dooley <conor@kernel.org>
Cc: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Will Deacon" <will@kernel.org>,
"Peter Zijlstra" <peterz@infradead.org>,
"Mark Rutland" <mark.rutland@arm.com>,
"Gary Guo" <gary@garyguo.net>,
"Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Chao-ying Fu" <chao-ying.fu@globalfoundries.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
torvalds@linux-foundation.org, olof@lixom.net,
aleksa.paunovic@htecgroup.com, arikalo@gmail.com,
"Boqun Feng" <boqun@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Luke Nelson" <luke.r.nels@gmail.com>,
"Xi Wang" <xi.wang@gmail.com>, "Björn Töpel" <bjorn@kernel.org>,
"Pu Lehui" <pulehui@huawei.com>,
"Puranjay Mohan" <puranjay@kernel.org>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Oleg Nesterov" <oleg@redhat.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, "Jonathan Corbet" <corbet@lwn.net>,
"Charlie Jenkins" <thecharlesjenkins@gmail.com>,
"Nam Cao" <namcao@linutronix.de>,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v6 2/6] riscv: build kernel atomics from LR/SC when Zaamo is disabled
Date: Wed, 11 Nov 2026 12:18:36 +0800 [thread overview]
Message-ID: <avPsnAlbfEsNa5zq@xhacker> (raw)
In-Reply-To: <20261110-revivable-saint-9bcfaa2fd0e7@spud>
On Tue, Nov 10, 2026 at 07:02:48PM +0000, Conor Dooley wrote:
> On Tue, Nov 10, 2026 at 03:20:59PM +0200, Vladimir Kondratiev wrote:
> > The A extension is Zaamo plus Zalrsc. On some CPUs Zaamo is present
> > only formally. MIPS P8700 traps every AMO instruction into M-mode and
> > emulates it there, so the extension is supported but very slow. A
> > typical uncontended atomic increment costs:
> >
> > native AMO 2..5 cycles
> > LR/SC, private L1 reservation monitor 6..12 cycles
> > LR/SC, PoC (L2) reservation monitor about 40 cycles
> > AMO emulated by an M-mode trap about 600 cycles
> >
> > The last two were measured on the eyeq7h hardware. On such a CPU the
> > kernel must use LR/SC for every atomic.
> >
> > Add RISCV_ISA_ZAAMO, default y. The default keeps "a" in -march and
> > the generated code unchanged. When it is disabled, -march carries
> > _zalrsc instead of "a", and atomic_*, bitops, xchg, futex and the
> > early boot code use LR/SC loops. The sequence is chosen with the
> > preprocessor, on CONFIG_RISCV_ISA_ZAAMO like the other ISA options in
> > the headers, because the assembler rejects AMO mnemonics once -march
> > lacks Zaamo. A kernel built this way runs on any hart that implements
> > A; it just does not use AMO. It is therefore a plain option, not a
> > NONPORTABLE one, and the hart keeps advertising "a" to userspace,
> > which is true.
> >
> > The LR/SC loops follow the ordering convention of the existing ones
> > in cmpxchg.h, from commit 5ce6c1f3535f ("riscv/atomic: Strengthen
> > implementations with fences") and commit 1d84afaf0252 ("riscv: Fix
> > fully ordered LR/SC xchg[8|16]() implementations"): a fully ordered
> > operation is lr, sc.rl and a trailing fence rw,rw; acquire is lr.aq
> > with a plain sc; release is a plain lr with sc.rl. The futex loop is
> > bounded to 128 retries and returns -EAGAIN after that, as arm64 does,
> > because userspace can keep the word changing from another thread and
> > futex_wake_op() retries on -EAGAIN anyway.
> >
> > Zabha, Zacas and the ssamoswap instruction of Zicfiss are AMO
> > instructions, so RISCV_ISA_ZABHA, RISCV_ISA_ZACAS and RISCV_USER_CFI
> > depend on RISCV_ISA_ZAAMO. The riscv64imac Rust target emits AMO too,
> > so RUSTC_SUPPORTS_RISCV depends on it as well.
> >
> > The choice is made at compile time rather than with alternatives.
> > Nearly every CPU has a native A extension, and an alternative would
> > inflate all those kernels with the nops needed to pad one AMO to the
> > size of an LR/SC loop, at every atomic site, for the benefit of a few.
> >
> > Turning Zaamo off needs a compiler that accepts _zaamo and _zalrsc in
> > -march. GCC 15.1 is the first release that does.
> > TOOLCHAIN_HAS_ZALRSC_ZAAMO checks for it; with an older compiler the
> > option stays at y.
> >
> > Three sets of extensions provide every atomic Linux needs. "a" is what
> > the kernel supports today. Zalrsc plus Ziccrse is what this patch adds:
> > every atomic is a constrained LR/SC loop, and Ziccrse is the
> > forward-progress guarantee for such loops. Zaamo plus Zacas would do
> > as well, with CAS loops in place of LR/SC as on x86, and is left for
> > whoever has such hardware.
> >
> > Suggested-by: Chao-ying Fu <chao-ying.fu@globalfoundries.com>
> > Nacked-by: Conor Dooley <conor.dooley@microchip.com>
> > Link: https://lore.kernel.org/linux-riscv/20261106-smock-headband-d6a7d568c228@spud/
>
> I had a quick glance at this revision, and I think you've at least tried
> to resolve the things I was pointing out. Did I miss something, or why
> have you kept the NAK after having resolved the things that I was
> objecting to?
>
I searched the maillist for this errata, or workaround or downgrading 'A'
or anything else it's named, found something interesting:
IIUC, Paul has rejected the series, at least call for "hold off on merging them"
see
https://lore.kernel.org/linux-riscv/8afa0702-4d30-86e2-5afb-a7c113a92dec@kernel.org/
and
https://lore.kernel.org/linux-riscv/6201870b-b50d-f6e2-814b-7a1fdbf064db@kernel.org/
But I'm not sure why the same series is still continuously sent out but
in different titles. I think this series can be ignored until riscv
maintainers agree to downgrade the 'A' to subset of 'A', I.E zalrsc
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-11-11 4:39 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 13:20 [PATCH v6 0/6] riscv: restrict the ISA used for atomics to avoid unsupported or slow AMO Vladimir Kondratiev
2026-11-10 13:20 ` Vladimir Kondratiev
2026-11-10 13:20 ` [PATCH v6 1/6] riscv: probes: reject probes inside an LR/SC sequence Vladimir Kondratiev
2026-11-10 13:20 ` Vladimir Kondratiev
2026-11-10 13:20 ` [PATCH v6 2/6] riscv: build kernel atomics from LR/SC when Zaamo is disabled Vladimir Kondratiev
2026-11-10 13:20 ` Vladimir Kondratiev
2026-11-10 19:02 ` Conor Dooley
2026-11-10 19:02 ` Conor Dooley
2026-11-11 4:18 ` Jisheng Zhang [this message]
2026-11-11 4:18 ` Jisheng Zhang
2026-11-11 6:37 ` Vladimir Kondratiev
2026-11-11 6:37 ` Vladimir Kondratiev
2026-11-10 13:21 ` [PATCH v6 3/6] riscv: accept the atomic extensions this kernel was built with Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 13:51 ` sashiko-bot
2026-11-10 13:21 ` [PATCH v6 4/6] riscv: report the A extension when Zaamo and Zalrsc are both present Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 13:21 ` [PATCH v6 5/6] riscv, bpf: emit LR/SC loops when Zaamo is disabled Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 14:00 ` sashiko-bot
2026-11-10 13:21 ` [PATCH v6 6/6] riscv: hwprobe: report whether AMO is faster than LR/SC Vladimir Kondratiev
2026-11-10 13:21 ` Vladimir Kondratiev
2026-11-10 14:04 ` sashiko-bot
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=avPsnAlbfEsNa5zq@xhacker \
--to=jszhang@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aleksa.paunovic@htecgroup.com \
--cc=alex@ghiti.fr \
--cc=aliceryhl@google.com \
--cc=andrii@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=arikalo@gmail.com \
--cc=ast@kernel.org \
--cc=bjorn3_gh@protonmail.com \
--cc=bjorn@kernel.org \
--cc=boqun@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chao-ying.fu@globalfoundries.com \
--cc=conor.dooley@microchip.com \
--cc=conor@kernel.org \
--cc=corbet@lwn.net \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=gary@garyguo.net \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=lossin@kernel.org \
--cc=luke.r.nels@gmail.com \
--cc=mark.rutland@arm.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mhiramat@kernel.org \
--cc=namcao@linutronix.de \
--cc=ojeda@kernel.org \
--cc=oleg@redhat.com \
--cc=olof@lixom.net \
--cc=palmer@dabbelt.com \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=song@kernel.org \
--cc=tamird@kernel.org \
--cc=thecharlesjenkins@gmail.com \
--cc=tmgross@umich.edu \
--cc=torvalds@linux-foundation.org \
--cc=vladimir.kondratiev@mobileye.com \
--cc=will@kernel.org \
--cc=work@onurozkan.dev \
--cc=xi.wang@gmail.com \
--cc=yonghong.song@linux.dev \
--cc=yury.norov@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.