[PATCH 06/10] locking/powerpc: Wire up local_try_cmpxchg
Uros Bizjak
ubizjak at gmail.com
Mon Mar 6 07:56:24 AEDT 2023
Implement target specific support for local_try_cmpxchg.
Cc: Michael Ellerman <mpe at ellerman.id.au>
Cc: Nicholas Piggin <npiggin at gmail.com>
Cc: Christophe Leroy <christophe.leroy at csgroup.eu>
Cc: Signed-off-by: Uros Bizjak <ubizjak at gmail.com>
Signed-off-by: Uros Bizjak <ubizjak at gmail.com>
---
arch/powerpc/include/asm/local.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/arch/powerpc/include/asm/local.h b/arch/powerpc/include/asm/local.h
index bc4bd19b7fc2..45492fb5bf22 100644
--- a/arch/powerpc/include/asm/local.h
+++ b/arch/powerpc/include/asm/local.h
@@ -90,6 +90,17 @@ static __inline__ long local_cmpxchg(local_t *l, long o, long n)
return t;
}
+static __inline__ bool local_try_cmpxchg(local_t *l, long *po, long n)
+{
+ long o = *po, r;
+
+ r = local_cmpxchg(l, o, n);
+ if (unlikely(r != o))
+ *po = r;
+
+ return likely(r == o);
+}
+
static __inline__ long local_xchg(local_t *l, long n)
{
long t;
--
2.39.2
More information about the Linuxppc-dev
mailing list