summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorLinus Torvalds2015-09-17 17:45:23 +0200
committerLinus Torvalds2015-09-17 17:45:23 +0200
commit9786cff38a31c452e32fd2f9a479dd7d19d91712 (patch)
tree1197c2e7a4e8973d19919f54f342fba6067488e2 /arch/x86
parentMerge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/ke... (diff)
parentlocking/static_keys: Fix up the static keys documentation (diff)
downloadkernel-qcow2-linux-9786cff38a31c452e32fd2f9a479dd7d19d91712.tar.gz
kernel-qcow2-linux-9786cff38a31c452e32fd2f9a479dd7d19d91712.tar.xz
kernel-qcow2-linux-9786cff38a31c452e32fd2f9a479dd7d19d91712.zip
Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull locking fixes from Ingo Molnar: "Spinlock performance regression fix, plus documentation fixes" * 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: locking/static_keys: Fix up the static keys documentation locking/qspinlock/x86: Only emit the test-and-set fallback when building guest support locking/qspinlock/x86: Fix performance regression under unaccelerated VMs locking/static_keys: Fix a silly typo
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/qspinlock.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/arch/x86/include/asm/qspinlock.h b/arch/x86/include/asm/qspinlock.h
index 9d51fae1cba3..eaba08076030 100644
--- a/arch/x86/include/asm/qspinlock.h
+++ b/arch/x86/include/asm/qspinlock.h
@@ -39,18 +39,27 @@ static inline void queued_spin_unlock(struct qspinlock *lock)
}
#endif
-#define virt_queued_spin_lock virt_queued_spin_lock
-
-static inline bool virt_queued_spin_lock(struct qspinlock *lock)
+#ifdef CONFIG_PARAVIRT
+#define virt_spin_lock virt_spin_lock
+static inline bool virt_spin_lock(struct qspinlock *lock)
{
if (!static_cpu_has(X86_FEATURE_HYPERVISOR))
return false;
- while (atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL) != 0)
- cpu_relax();
+ /*
+ * On hypervisors without PARAVIRT_SPINLOCKS support we fall
+ * back to a Test-and-Set spinlock, because fair locks have
+ * horrible lock 'holder' preemption issues.
+ */
+
+ do {
+ while (atomic_read(&lock->val) != 0)
+ cpu_relax();
+ } while (atomic_cmpxchg(&lock->val, 0, _Q_LOCKED_VAL) != 0);
return true;
}
+#endif /* CONFIG_PARAVIRT */
#include <asm-generic/qspinlock.h>