Skip to contentSkip to conversation

ARM: mcs lock: implement wfe-based polling for MCS locking

PATCH Superseded Will Deacon 1 participant 1 message Apr 17, 2014 Arm (32-bit)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: mcs lock: implement wfe-based polling for MCS locking

This patch introduces a wfe-based polling loop for spinning on contended MCS locks and waking up corresponding waiters when the lock is released.

---
 arch/arm/include/asm/mcs_spinlock.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 arch/arm/include/asm/mcs_spinlock.h
arch/arm/include/asm/mcs_spinlock.h new file +20 -0
new file mode 100644
index 000000000000..f32f97e81471
@@ -0,0 +1,20 @@
+#ifndef __ASM_MCS_LOCK_H
+#define __ASM_MCS_LOCK_H
+
+/* MCS spin-locking. */
+#define arch_mcs_spin_lock_contended(lock)				\
+do {									\
+	/* Ensure prior stores are observed before we enter wfe. */	\
+	smp_mb();							\
+	while (!(smp_load_acquire(lock)))				\
+		wfe();							\
+} while (0)								\
+
+#define arch_mcs_spin_unlock_contended(lock)				\
+do {									\
+	smp_store_release(lock, 1);					\
+	dsb(ishst);							\
+	sev();								\
+} while (0)
+
+#endif	/* __ASM_MCS_LOCK_H */
Signature · 1 line
1.9.1