Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031122AbbEEJGr (ORCPT ); Tue, 5 May 2015 05:06:47 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48348 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031094AbbEEJGm (ORCPT ); Tue, 5 May 2015 05:06:42 -0400 Date: Tue, 5 May 2015 02:06:29 -0700 From: tip-bot for Tahsin Erdogan Message-ID: Cc: hpa@zytor.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, tahsin@google.com, mingo@kernel.org Reply-To: tahsin@google.com, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com In-Reply-To: <1430799331-20445-1-git-send-email-tahsin@google.com> References: <1430799331-20445-1-git-send-email-tahsin@google.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/spinlocks: Fix regression in spinlock contention detection Git-Commit-ID: e8a4a2696fecb398b0288c43c0e0dbb91e265bb2 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2183 Lines: 51 Commit-ID: e8a4a2696fecb398b0288c43c0e0dbb91e265bb2 Gitweb: http://git.kernel.org/tip/e8a4a2696fecb398b0288c43c0e0dbb91e265bb2 Author: Tahsin Erdogan AuthorDate: Mon, 4 May 2015 21:15:31 -0700 Committer: Thomas Gleixner CommitDate: Tue, 5 May 2015 11:01:38 +0200 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: d6abfdb20223 ("x86/spinlocks/paravirt: Fix memory corruption on unlock") Signed-off-by: Tahsin Erdogan 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/