[PATCH] powerpc: Fix spin_event_timeout() to be robust over context switches

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE6285d

2 messages, 2 authors, 2009-06-30 · open the first message on its own page

[PATCH] powerpc: Fix spin_event_timeout() to be robust over context switches

From: Grant Likely <hidden>
Date: 2009-06-29 23:40:59

From: Grant Likely <redacted>

Current implementation of spin_event_timeout can be interrupted by an
IRQ or context switch after testing the condition, but before checking
the timeout.  This can cause the loop to report a timeout when the
condition actually became true in the middle.

This patch adds one final check of the condition upon exit of the loop
if the last test of the condition was still false.

Signed-off-by: Grant Likely <redacted>
---

 arch/powerpc/include/asm/delay.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h
index 1e2eb41..52e4d54 100644
--- a/arch/powerpc/include/asm/delay.h
+++ b/arch/powerpc/include/asm/delay.h
@@ -63,6 +63,8 @@ extern void udelay(unsigned long usecs);
 			udelay(delay);                                         \
 		else                                                           \
 			cpu_relax();                                           \
+	if (!__ret)                                                            \
+		__ret = (condition);                                           \
 	__ret;		                                                       \
 })
 

Re: [PATCH] powerpc: Fix spin_event_timeout() to be robust over context switches

From: Timur Tabi <hidden>
Date: 2009-06-30 15:02:56

On Mon, Jun 29, 2009 at 6:40 PM, Grant Likely[off-list ref] wr=
ote:
From: Grant Likely <redacted>

Current implementation of spin_event_timeout can be interrupted by an
IRQ or context switch after testing the condition, but before checking
the timeout. =A0This can cause the loop to report a timeout when the
condition actually became true in the middle.

This patch adds one final check of the condition upon exit of the loop
if the last test of the condition was still false.

Signed-off-by: Grant Likely <redacted>
Acked-by: Timur Tabi <redacted>

Ben, please pick this up for the next rc of 2.6.31.

--=20
Timur Tabi
Linux kernel developer at Freescale
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help