All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/spinlocks: Fix regression in spinlock contention detection
@ 2015-05-05  4:15 Tahsin Erdogan
  2015-05-05  9:06 ` [tip:x86/urgent] " tip-bot for Tahsin Erdogan
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Tahsin Erdogan @ 2015-05-05  4:15 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86
  Cc: peterz, Waiman.Long, borntraeger, oleg, raghavendra.kt,
	linux-kernel, Tahsin Erdogan

A spinlock is regarded as contended when there is at least one waiter.
Currently, the code that checks whether there are any waiters rely on
tail value being greater than head. However, this is not true if tail
reaches the max value and wraps back to zero, so arch_spin_is_contended()
incorrectly returns 0 (not contended) when tail is smaller than head.

The original code (before regression) handled this case by casting the
(tail - head) to an unsigned value. This change simply restores that
behavior.

Fixes: d6abfdb20223 ("x86/spinlocks/paravirt: Fix memory corruption on
unlock")
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
---
 arch/x86/include/asm/spinlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index cf87de3..64b6117 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -169,7 +169,7 @@ static inline int arch_spin_is_contended(arch_spinlock_t *lock)
 	struct __raw_tickets tmp = READ_ONCE(lock->tickets);
 
 	tmp.head &= ~TICKET_SLOWPATH_FLAG;
-	return (tmp.tail - tmp.head) > TICKET_LOCK_INC;
+	return (__ticket_t)(tmp.tail - tmp.head) > TICKET_LOCK_INC;
 }
 #define arch_spin_is_contended	arch_spin_is_contended
 
-- 
2.2.0.rc0.207.ga3a616c


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

end of thread, other threads:[~2015-05-08 11:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05  4:15 [PATCH] x86/spinlocks: Fix regression in spinlock contention detection Tahsin Erdogan
2015-05-05  9:06 ` [tip:x86/urgent] " tip-bot for Tahsin Erdogan
2015-05-05  9:17 ` [PATCH] " Peter Zijlstra
2015-05-05 10:38   ` Raghavendra K T
2015-05-05 10:58     ` Peter Zijlstra
2015-05-05 14:10       ` Tahsin Erdogan
2015-05-05 14:30         ` Peter Zijlstra
     [not found]       ` <CAAeU0aPSDdDVKm=YgbYH+SWfk07rLGgEFMQoN+nt4vc1_YLHzg@mail.gmail.com>
2015-05-05 15:25         ` Raghavendra K T
2015-05-05 15:28           ` Tahsin Erdogan
2015-05-05 15:32           ` Waiman Long
2015-05-05 15:38             ` Raghavendra K T
2015-05-06 15:37 ` Raghavendra K T
2015-05-07  7:13   ` Tahsin Erdogan
2015-05-08 11:09     ` Greg KH

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.