|
|
|
|
|
|
|
|
|
|
xen-devel
[Xen-devel] [PATCH 13/20] x86/pvticketlock: make sure unlock is seen by
To: |
Peter Zijlstra <peterz@xxxxxxxxxxxxx> |
Subject: |
[Xen-devel] [PATCH 13/20] x86/pvticketlock: make sure unlock is seen by everyone before checking waiters |
From: |
Jeremy Fitzhardinge <jeremy@xxxxxxxx> |
Date: |
Wed, 3 Nov 2010 10:59:54 -0400 |
Cc: |
Nick Piggin <npiggin@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Srivatsa Vaddagiri <vatsa@xxxxxxxxxxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxxxx>, Linux Virtualization <virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx>, Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>, Avi Kivity <avi@xxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx> |
Delivery-date: |
Wed, 03 Nov 2010 08:23:27 -0700 |
Envelope-to: |
www-data@xxxxxxxxxxxxxxxxxxx |
In-reply-to: |
<cover.1288794124.git.jeremy.fitzhardinge@xxxxxxxxxx> |
In-reply-to: |
<cover.1288794124.git.jeremy.fitzhardinge@xxxxxxxxxx> |
List-help: |
<mailto:xen-devel-request@lists.xensource.com?subject=help> |
List-id: |
Xen developer discussion <xen-devel.lists.xensource.com> |
List-post: |
<mailto:xen-devel@lists.xensource.com> |
List-subscribe: |
<http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe> |
List-unsubscribe: |
<http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe> |
References: |
<cover.1288794124.git.jeremy.fitzhardinge@xxxxxxxxxx> |
References: |
<cover.1288794124.git.jeremy.fitzhardinge@xxxxxxxxxx> |
Sender: |
xen-devel-bounces@xxxxxxxxxxxxxxxxxxx |
From: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
If we don't put a real memory barrier between the unlocking increment
of the queue head and the check for lock waiters, we can end up with a
deadlock as a result of the unload write being reordered with respect
to the waiters read. In effect, the check on the waiters count could
happen before the unlock, which leads to a deadlock:
unlocker locker
check waiters (none)
check lock head (timeout)
add to waiters
block
release lock => deadlock
Adding a mb() barrier prevents the unlocker's waiter check from happening
before the lock release.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
---
arch/x86/include/asm/spinlock.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
index 3deabca..b9a1aae 100644
--- a/arch/x86/include/asm/spinlock.h
+++ b/arch/x86/include/asm/spinlock.h
@@ -88,6 +88,13 @@ static inline void __ticket_sub_waiting(struct arch_spinlock
*lock)
static __always_inline bool __ticket_lock_waiters(const struct arch_spinlock
*lock)
{
+ /*
+ * Make sure everyone sees the unlock write before we check the
+ * waiting count. The processor ordering doesn't guarantee this
+ * because they're different memory locations.
+ */
+ mb();
+
return ACCESS_ONCE(lock->waiting) != 0;
}
#endif /* CONFIG_PARAVIRT_SPINLOCKS */
--
1.7.2.3
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|
<Prev in Thread] |
Current Thread |
[Next in Thread>
|
- [Xen-devel] [PATCH 12/20] x86/pvticketlock: use callee-save for unlock_kick as well, (continued)
- [Xen-devel] [PATCH 12/20] x86/pvticketlock: use callee-save for unlock_kick as well, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 17/20] x86/ticketlock: clarify barrier in arch_spin_lock, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 14/20] x86/ticketlock: loosen ordering restraints on unlock, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 16/20] x86/ticketlock: don't inline _spin_unlock when using paravirt spinlocks, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 09/20] xen/pvticketlock: Xen implementation for PV ticket locks, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 05/20] x86/ticketlock: make __ticket_spin_lock common, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 10/20] x86/pvticketlock: keep count of blocked cpus, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 20/20] x86/ticketlock: rename ticketpair to head_tail, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 07/20] x86/spinlocks: replace pv spinlocks with pv ticketlocks, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 15/20] x86/ticketlock: prevent compiler reordering into locked region, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 13/20] x86/pvticketlock: make sure unlock is seen by everyone before checking waiters,
Jeremy Fitzhardinge <=
- [Xen-devel] [PATCH 02/20] x86/ticketlock: convert spin loop to C, Jeremy Fitzhardinge
- [Xen-devel] [PATCH 19/20] x86/ticketlocks: use overlapping read to eliminate mb(), Jeremy Fitzhardinge
- [Xen-devel] [PATCH 18/20] x86/ticketlock: remove .slock, Jeremy Fitzhardinge
- [Xen-devel] Re: [PATCH 00/20] x86: ticket lock rewrite and paravirtualization, H. Peter Anvin
|
|
|
|
|