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

David Laight david.laight.linux at gmail.com
Sun Nov 8 13:32:54 PST 2026


On Sun,  8 Nov 2026 19:04:04 +0800
Yunhui Cui <cuiyunhui at bytedance.com> 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



More information about the linux-riscv mailing list