[PATCH v12 06/10] riscv: implement preemptible this_cpu add_return operations
From: Yunhui Cui
Date: Fri Dec 04 2026 - 04:01:36 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 6d0a11b49563f..f67dc601287eb 100644
--- a/arch/riscv/include/asm/percpu.h
+++ b/arch/riscv/include/asm/percpu.h
@@ -281,6 +281,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
--
2.39.5