From 89b310c5192e75cfd1844c324cb8a92e2bc414c8 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 18 Dec 2020 21:48:35 +0000 Subject: [PATCH] Implements SPIN_LOCK macro for ARM. using yield instruction which is the x86's "pause" equivalent. Signed-off-by: David Carlier --- src/include/storage/s_lock.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 31a5ca6fb3..b4d1d1f515 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -336,6 +336,29 @@ tas(volatile slock_t *lock) #define S_UNLOCK(lock) __sync_lock_release(lock) +#if defined(__aarch64__) || __ARM_ARCH__ >= 7 + +#define SPIN_LOCK spin_delay + +static __inline__ void +spin_delay(void) +{ + /* + * With spin locks, the yield hint + * improves CPU usage and performance + * on ARM hardwares implemented on 64 bits + * but is a NOP on ARM11 for example thus + * enabling this instruction when useful. + */ + __asm__ __volatile__( + " yield \n" +: +: +: "memory"); + +} + +#endif /* __aarch64__ || __ARM_ARCH__ >= 7 */ #endif /* HAVE_GCC__SYNC_INT32_TAS */ #endif /* __arm__ || __arm || __aarch64__ || __aarch64 */ -- 2.20.1