Skip to contentSkip to conversation

arm64: cmpwait: Clear event register before arming exclusive monitor

PATCH New Will Deacon 2 participants 2 messages Apr 30, 2018 – May 16, 2018 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: cmpwait: Clear event register before arming exclusive monitor

When waiting for a cacheline to change state in cmpwait, we may immediately wake-up the first time around the outer loop if the event register was already set (for example, because of the event stream).

Avoid these spurious wakeups by explicitly clearing the event register before loading the cacheline and setting the exclusive monitor.

---
 arch/arm64/include/asm/cmpxchg.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm64/include/asm/cmpxchg.h +3 -1
index 4f5fd2a36e6e..3b0938281541 100644
@@ -204,7 +204,9 @@ static inline void __cmpwait_case_##name(volatile void *ptr,		\
 	unsigned long tmp;						\
 									\
 	asm volatile(							\
-	"	ldxr" #sz "\t%" #w "[tmp], %[v]\n"		\
+	"	sevl\n"							\
+	"	wfe\n"							\
+	"	ldxr" #sz "\t%" #w "[tmp], %[v]\n"			\
 	"	eor	%" #w "[tmp], %" #w "[tmp], %" #w "[val]\n"	\
 	"	cbnz	%" #w "[tmp], 1f\n"				\
 	"	wfe\n"							\
Signature · 1 line
2.1.4
maintainer Applied
#1 lore raw

PATCH 1/1 arm64: cmpwait: Clear event register before arming exclusive monitor

Quoted 8 lines · Will Deacon

When waiting for a cacheline to change state in cmpwait, we may immediately wake-up the first time around the outer loop if the event register was already set (for example, because of the event stream).

Avoid these spurious wakeups by explicitly clearing the event register before loading the cacheline and setting the exclusive monitor.

Queued for 4.18. Thanks.

Signature · 1 line
Catalin