2024-05-28 14:45:38

by Uros Bizjak

[permalink] [raw]
Subject: [PATCH v2 1/2] percpu: Add __this_cpu_try_cmpxchg()

Add __this_cpu_try_cmpxchg() version of the percpu op.

Signed-off-by: Uros Bizjak <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Uladzislau Rezki <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Dennis Zhou <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Christoph Lameter <[email protected]>
---
include/linux/percpu-defs.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index ec3573119923..8efce7414fad 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -475,6 +475,12 @@ do { \
raw_cpu_cmpxchg(pcp, oval, nval); \
})

+#define __this_cpu_try_cmpxchg(pcp, ovalp, nval) \
+({ \
+ __this_cpu_preempt_check("try_cmpxchg"); \
+ raw_cpu_try_cmpxchg(pcp, ovalp, nval); \
+})
+
#define __this_cpu_sub(pcp, val) __this_cpu_add(pcp, -(typeof(pcp))(val))
#define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1)
#define __this_cpu_dec(pcp) __this_cpu_sub(pcp, 1)
--
2.42.0



2024-05-28 18:50:33

by Uladzislau Rezki

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] percpu: Add __this_cpu_try_cmpxchg()

On Tue, May 28, 2024 at 04:43:13PM +0200, Uros Bizjak wrote:
> Add __this_cpu_try_cmpxchg() version of the percpu op.
>
> Signed-off-by: Uros Bizjak <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Uladzislau Rezki <[email protected]>
> Cc: Christoph Hellwig <[email protected]>
> Cc: Lorenzo Stoakes <[email protected]>
> Cc: Dennis Zhou <[email protected]>
> Cc: Tejun Heo <[email protected]>
> Cc: Christoph Lameter <[email protected]>
> ---
> include/linux/percpu-defs.h | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
> index ec3573119923..8efce7414fad 100644
> --- a/include/linux/percpu-defs.h
> +++ b/include/linux/percpu-defs.h
> @@ -475,6 +475,12 @@ do { \
> raw_cpu_cmpxchg(pcp, oval, nval); \
> })
>
> +#define __this_cpu_try_cmpxchg(pcp, ovalp, nval) \
> +({ \
> + __this_cpu_preempt_check("try_cmpxchg"); \
> + raw_cpu_try_cmpxchg(pcp, ovalp, nval); \
> +})
> +
> #define __this_cpu_sub(pcp, val) __this_cpu_add(pcp, -(typeof(pcp))(val))
> #define __this_cpu_inc(pcp) __this_cpu_add(pcp, 1)
> #define __this_cpu_dec(pcp) __this_cpu_sub(pcp, 1)
> --
> 2.42.0
>
Acked-by: Uladzislau Rezki (Sony) <[email protected]>

Thanks!

--
Uladzislau Rezki