Skip to contentSkip to conversation

mutex: Better control mutex adaptive spinning config

PATCH In review Frederic Weisbecker 1 participant 4 messages Dec 2, 2009 – Dec 3, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mutex: Better control mutex adaptive spinning config

Introduce CONFIG_MUTEX_SPIN_ON_OWNER so that we can centralize in a single place the conditions that determine its definition and use.

---
 kernel/Kconfig.locks |    3 +++
 kernel/mutex.c       |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
kernel/Kconfig.locks +3 -0
index d1f86db..88c92fb 100644
@@ -197,3 +197,6 @@ config INLINE_WRITE_UNLOCK_IRQ
 
 config INLINE_WRITE_UNLOCK_IRQRESTORE
 	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
+
+config MUTEX_SPIN_ON_OWNER
+	def_bool SMP && !DEBUG_MUTEXES && !HAVE_DEFAULT_NO_SPIN_MUTEXES
kernel/mutex.c +2 -2
index 947b3ad..632f04c 100644
@@ -148,8 +148,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 
 	preempt_disable();
 	mutex_acquire(&lock->dep_map, subclass, 0, ip);
-#if defined(CONFIG_SMP) && !defined(CONFIG_DEBUG_MUTEXES) && \
-    !defined(CONFIG_HAVE_DEFAULT_NO_SPIN_MUTEXES)
+
+#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
 	/*
 	 * Optimistic spinning.
 	 *
Signature · 1 line
1.6.2.3
#1 lore raw

PATCH 2/2 mutex: Fix missing conditions to build mutex_spin_on_owner()

We don't need to build mutex_spin_on_owner() if we have CONFIG_DEBUG_MUTEXES or CONFIG_HAVE_DEFAULT_NO_SPIN_MUTEXES as it won't be used under such configs.

Use CONFIG_MUTEX_SPIN_ON_OWNER as it gathers all the necessary checks before building it.

---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +1 -1
index 7b1b2b5..aa31244 100644
@@ -5527,7 +5527,7 @@ need_resched_nonpreemptible:
 }
 EXPORT_SYMBOL(schedule);
 
-#ifdef CONFIG_SMP
+#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
 /*
  * Look out! "owner" is an entirely speculative pointer
  * access and not reliable.
Signature · 1 line
1.6.2.3
#2 lore raw

[tip:core/locking] mutex: Fix missing conditions to build mutex_spin_on_owner()

Commit-ID:  c08f782985eed9959438368e84ce1d7f2ed03d95
Gitweb:     http://git.kernel.org/tip/c08f782985eed9959438368e84ce1d7f2ed03d95
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Wed, 2 Dec 2009 20:49:17 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 3 Dec 2009 11:50:11 +0100

mutex: Fix missing conditions to build mutex_spin_on_owner()

We don't need to build mutex_spin_on_owner() if we have CONFIG_DEBUG_MUTEXES or CONFIG_HAVE_DEFAULT_NO_SPIN_MUTEXES as it won't be used under such configs.

Use CONFIG_MUTEX_SPIN_ON_OWNER as it gathers all the necessary checks before building it.

LKML-Reference: <[email protected]>

Cc Peter Zijlstra <[email protected]>
---
 kernel/sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/sched.c +1 -1
index 3c11ae0..ec0af1f 100644
@@ -5481,7 +5481,7 @@ need_resched_nonpreemptible:
 }
 EXPORT_SYMBOL(schedule);
 
-#ifdef CONFIG_SMP
+#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
 /*
  * Look out! "owner" is an entirely speculative pointer
  * access and not reliable.
#3 lore raw
In reply to Frederic Weisbecker
Commit-ID:  c02260277e472095ffb3ad893be5eeab9dcefde3
Gitweb:     http://git.kernel.org/tip/c02260277e472095ffb3ad893be5eeab9dcefde3
Author:     Frederic Weisbecker <[email protected]>
AuthorDate: Wed, 2 Dec 2009 20:49:16 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 3 Dec 2009 11:50:11 +0100

mutex: Better control mutex adaptive spinning config

Introduce CONFIG_MUTEX_SPIN_ON_OWNER so that we can centralize in a single place the conditions that determine its definition and use.

LKML-Reference: <[email protected]>

Cc Peter Zijlstra <[email protected]>
---
 kernel/Kconfig.locks |    3 +++
 kernel/mutex.c       |    4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
kernel/Kconfig.locks +3 -0
index d1f86db..88c92fb 100644
@@ -197,3 +197,6 @@ config INLINE_WRITE_UNLOCK_IRQ
 
 config INLINE_WRITE_UNLOCK_IRQRESTORE
 	def_bool !DEBUG_SPINLOCK && ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
+
+config MUTEX_SPIN_ON_OWNER
+	def_bool SMP && !DEBUG_MUTEXES && !HAVE_DEFAULT_NO_SPIN_MUTEXES
kernel/mutex.c +2 -2
index 947b3ad..632f04c 100644
@@ -148,8 +148,8 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 
 	preempt_disable();
 	mutex_acquire(&lock->dep_map, subclass, 0, ip);
-#if defined(CONFIG_SMP) && !defined(CONFIG_DEBUG_MUTEXES) && \
-    !defined(CONFIG_HAVE_DEFAULT_NO_SPIN_MUTEXES)
+
+#ifdef CONFIG_MUTEX_SPIN_ON_OWNER
 	/*
 	 * Optimistic spinning.
 	 *