Re: [External] Re: [PATCH v10 5/9] riscv: implement preemptible this_cpu add_return operations
From: yunhui cui
Date: Thu Dec 03 2026 - 07:46:02 EST
Hi David,
On Thu, Nov 12, 2026 at 8:09 PM David Laight
<david.laight.linux@xxxxxxxxx> wrote:
>
> On Thu, 12 Nov 2026 18:41:45 +0800
> Yunhui Cui <cuiyunhui@xxxxxxxxxxxxx> wrote:
>
> > Apply the recoverable per-CPU address handling to add-return operations.
> >
> > Native-width AMOs return the old value, so derive the new value required
> > by the percpu API from the operand. Use Zabha for subword operations when
> > available, or a masked LR/SC sequence that returns the updated field.
>
> I can't help feeling that some of this code is the same as that for
> normal atomic accesses.
> Can they me merged?
In next version, this_cpu_add() and this_cpu_add_return() share the same
implementation, and exchange reuses the common AMO helper where
available. The exchange LR/SC fallback and the compare-exchange
sequences stay separate.
Thanks,
Yunhui
>
> David