From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755619Ab0KCPD3 (ORCPT ); Wed, 3 Nov 2010 11:03:29 -0400 Received: from claw.goop.org ([74.207.240.146]:35222 "EHLO claw.goop.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755443Ab0KCPBL (ORCPT ); Wed, 3 Nov 2010 11:01:11 -0400 From: Jeremy Fitzhardinge To: Peter Zijlstra Cc: Linux Kernel Mailing List , Nick Piggin , Jan Beulich , Avi Kivity , Xen-devel , "H. Peter Anvin" , Linux Virtualization , Srivatsa Vaddagiri , Jeremy Fitzhardinge Subject: [PATCH 14/20] x86/ticketlock: loosen ordering restraints on unlock Date: Wed, 3 Nov 2010 10:59:55 -0400 Message-Id: <1de42e70d22a5078d65d6d943da06c9ea0f4691b.1288794124.git.jeremy.fitzhardinge@citrix.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jeremy Fitzhardinge It's only necessary to prevent the compiler from reordering code out of the locked region past the unlock. Putting too many barriers in prevents the compiler from generating the best code when PV spinlocks are enabled. Signed-off-by: Jeremy Fitzhardinge --- arch/x86/include/asm/spinlock.h | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h index b9a1aae..d6de5e7 100644 --- a/arch/x86/include/asm/spinlock.h +++ b/arch/x86/include/asm/spinlock.h @@ -46,9 +46,7 @@ static __always_inline void __ticket_unlock_release(struct arch_spinlock *lock) #else static __always_inline void __ticket_unlock_release(struct arch_spinlock *lock) { - barrier(); lock->tickets.head++; - barrier(); } #endif @@ -184,7 +182,11 @@ static __always_inline int arch_spin_trylock(arch_spinlock_t *lock) static __always_inline void arch_spin_unlock(arch_spinlock_t *lock) { - __ticket_t next = lock->tickets.head + 1; + __ticket_t next; + + barrier(); /* prevent reordering out of locked region */ + + next = lock->tickets.head + 1; __ticket_unlock_release(lock); __ticket_unlock_kick(lock, next); } -- 1.7.2.3