[PATCH v11 06/10] riscv: implement preemptible this_cpu add_return operations
From: Yunhui Cui
Date: Thu Dec 03 2026 - 08:57:10 EST
Apply the recoverable per-CPU address handling to add-return operations.
Use the common add helpers and value-returning wrapper so void and
add-return operations share the same atomic implementation.
Signed-off-by: Yunhui Cui <cuiyunhui@xxxxxxxxxxxxx>
---
arch/riscv/include/asm/percpu.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/riscv/include/asm/percpu.h b/arch/riscv/include/asm/percpu.h
index e39210ddd5026..939a0fef7246c 100644
--- a/arch/riscv/include/asm/percpu.h
+++ b/arch/riscv/include/asm/percpu.h
@@ -279,6 +279,17 @@ __PERCPU_8_16_OP_CASE(or, 16, .h, |)
#define this_cpu_or_8(pcp, val) _pcp_wrap(__percpu_or_amo_case_64, pcp, val)
#endif
+#define this_cpu_add_return_1(pcp, val) \
+ _pcp_wrap_return(__percpu_add_amo_case_8, pcp, val)
+#define this_cpu_add_return_2(pcp, val) \
+ _pcp_wrap_return(__percpu_add_amo_case_16, pcp, val)
+#define this_cpu_add_return_4(pcp, val) \
+ _pcp_wrap_return(__percpu_add_amo_case_32, pcp, val)
+#ifdef CONFIG_64BIT
+#define this_cpu_add_return_8(pcp, val) \
+ _pcp_wrap_return(__percpu_add_amo_case_64, pcp, val)
+#endif
+
#undef __PERCPU_AMO
#undef PERCPU_RW_OPS
#undef __PERCPU_AMO_OP_CASE