Skip to contentSkip to conversation

locking fixes

GIT PULL Ingo Molnar 1 participant 1 message Sep 17, 2015

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

Linus,

Please pull the latest locking-urgent-for-linus git tree from:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking-urgent-for-linus

# HEAD: 1975dbc276c6ab62230cf4f9df5ddc9ff0e0e473 locking/static_keys: Fix up the static keys documentation

Spinlock performance regression fix, plus documentation fixes.

Thanks,

Ingo

------------------>
Jonathan Corbet (2):
locking/static_keys: Fix a silly typo locking/static_keys: Fix up the static keys documentation

Peter Zijlstra (2):
locking/qspinlock/x86: Fix performance regression under unaccelerated VMs locking/qspinlock/x86: Only emit the test-and-set fallback when building guest support

 Documentation/static-keys.txt    |  4 ++--
 arch/x86/include/asm/qspinlock.h | 19 ++++++++++++++-----
 include/asm-generic/qspinlock.h  |  4 ++--
 include/linux/jump_label.h       | 10 ++++------
 kernel/locking/qspinlock.c       |  2 +-
 5 files changed, 23 insertions(+), 16 deletions(-)
Documentation/static-keys.txt +2 -2
index f4cb0b2d5cd7..477927becacb 100644
@@ -15,8 +15,8 @@ static_key_false()
 
 DEFINE_STATIC_KEY_TRUE(key);
 DEFINE_STATIC_KEY_FALSE(key);
-static_key_likely()
-statick_key_unlikely()
+static_branch_likely()
+static_branch_unlikely()
 
 0) Abstract
 
arch/x86/include/asm/qspinlock.h +14 -5
index 9d51fae1cba3..eaba08076030 100644
@@ -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>
 
include/asm-generic/qspinlock.h +2 -2
index 83bfb87f5bf1..e2aadbc7151f 100644
@@ -111,8 +111,8 @@ static inline void queued_spin_unlock_wait(struct qspinlock *lock)
 		cpu_relax();
 }
 
-#ifndef virt_queued_spin_lock
-static __always_inline bool virt_queued_spin_lock(struct qspinlock *lock)
+#ifndef virt_spin_lock
+static __always_inline bool virt_spin_lock(struct qspinlock *lock)
 {
 	return false;
 }
include/linux/jump_label.h +4 -6
index 7f653e8f6690..f1094238ab2a 100644
@@ -21,8 +21,8 @@
  *
  * DEFINE_STATIC_KEY_TRUE(key);
  * DEFINE_STATIC_KEY_FALSE(key);
- * static_key_likely()
- * statick_key_unlikely()
+ * static_branch_likely()
+ * static_branch_unlikely()
  *
  * Jump labels provide an interface to generate dynamic branches using
  * self-modifying code. Assuming toolchain and architecture support, if we
@@ -45,12 +45,10 @@
  * statement, setting the key to true requires us to patch in a jump
  * to the out-of-line of true branch.
  *
- * In addtion to static_branch_{enable,disable}, we can also reference count
+ * In addition to static_branch_{enable,disable}, we can also reference count
  * the key or branch direction via static_branch_{inc,dec}. Thus,
  * static_branch_inc() can be thought of as a 'make more true' and
- * static_branch_dec() as a 'make more false'. The inc()/dec()
- * interface is meant to be used exclusively from the inc()/dec() for a given
- * key.
+ * static_branch_dec() as a 'make more false'.
  *
  * Since this relies on modifying code, the branch modifying functions
  * must be considered absolute slow paths (machine wide synchronization etc.).
kernel/locking/qspinlock.c +1 -1
index 337c8818541d..87e9ce6a63c5 100644
@@ -289,7 +289,7 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)
 	if (pv_enabled())
 		goto queue;
 
-	if (virt_queued_spin_lock(lock))
+	if (virt_spin_lock(lock))
 		return;
 
 	/*