]> git.baikalelectronics.ru Git - kernel.git/commit
x86/spinlocks: Fix regression in spinlock contention detection
authorTahsin Erdogan <tahsin@google.com>
Tue, 5 May 2015 04:15:31 +0000 (21:15 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 5 May 2015 09:01:38 +0000 (11:01 +0200)
commitfbe79b92c5cbc690f1ad0e637fe4ea2e537c36b6
tree61b8b75b02cfbb8a6634792b8c686bd4e8ca01c5
parent3e33189259d7b897db25bc165835dbab67e745e0
x86/spinlocks: Fix regression in spinlock contention detection

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: 616e849514b4 ("x86/spinlocks/paravirt: Fix memory corruption on unlock")
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Cc: peterz@infradead.org
Cc: Waiman.Long@hp.com
Cc: borntraeger@de.ibm.com
Cc: oleg@redhat.com
Cc: raghavendra.kt@linux.vnet.ibm.com
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/1430799331-20445-1-git-send-email-tahsin@google.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/include/asm/spinlock.h