Re: [PATCH v9 1/3] riscv: implement this_cpu operations

From: David Laight

Date: Sun Nov 08 2026 - 16:33:09 EST


On Sun, 8 Nov 2026 19:04:04 +0800
Yunhui Cui <cuiyunhui@xxxxxxxxxxxxx> wrote:

> RISC-V has no asm/percpu.h, so this_cpu_*() read-modify-write
> operations use generic implementations that disable local interrupts.
>
> Implement RISC-V-specific this_cpu operations with preemption disabled
> to keep accesses on the current CPU.

Have you looked at some of the schemes (I think arm64 has the latest,
but also s390) that do most per-cpu ops without disabling preemption.
In particular they save the pre-emption check when pre-emption
is enabled.

Basically the code tells the scheduler which register contains the
per-cpu data so that it can be 'magically' flipped during a context
switch.

David