All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: cmpwait: Clear event register before arming exclusive monitor
@ 2018-04-30 12:56 Will Deacon
  2018-05-16 11:22 ` Catalin Marinas
  0 siblings, 1 reply; 2+ messages in thread
From: Will Deacon @ 2018-04-30 12:56 UTC (permalink / raw)
  To: linux-arm-kernel

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.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/cmpxchg.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
index 4f5fd2a36e6e..3b0938281541 100644
--- a/arch/arm64/include/asm/cmpxchg.h
+++ b/arch/arm64/include/asm/cmpxchg.h
@@ -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"							\
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] arm64: cmpwait: Clear event register before arming exclusive monitor
  2018-04-30 12:56 [PATCH] arm64: cmpwait: Clear event register before arming exclusive monitor Will Deacon
@ 2018-05-16 11:22 ` Catalin Marinas
  0 siblings, 0 replies; 2+ messages in thread
From: Catalin Marinas @ 2018-05-16 11:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Apr 30, 2018 at 01:56:32PM +0100, Will Deacon wrote:
> 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.
> 
> Signed-off-by: Will Deacon <will.deacon@arm.com>

Queued for 4.18. Thanks.

-- 
Catalin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-16 11:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-30 12:56 [PATCH] arm64: cmpwait: Clear event register before arming exclusive monitor Will Deacon
2018-05-16 11:22 ` Catalin Marinas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.