[PATCH [RT] 14/14] sysctl for runtime-control of lateral mutex stealing

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Gregory Haskins
Date: Thursday, February 21, 2008 - 8:27 am

From: Sven-Thorsten Dietrich <sdietrich@novell.com>

Add /proc/sys/kernel/lateral_steal, to allow switching on and off
equal-priority mutex stealing between threads.

Signed-off-by: Sven-Thorsten Dietrich <sdietrich@suse.de>
---

 kernel/rtmutex.c |    8 ++++++--
 kernel/sysctl.c  |   14 ++++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index da077e5..62e7af5 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -27,6 +27,9 @@ int rtlock_timeout __read_mostly = CONFIG_RTLOCK_DELAY;
 #ifdef CONFIG_ADAPTIVE_RTMUTEX
 int rtmutex_timeout __read_mostly = CONFIG_RTMUTEX_DELAY;
 #endif
+#ifdef CONFIG_RTLOCK_LATERAL_STEAL
+int rtmutex_lateral_steal __read_mostly = 1;
+#endif
 
 /*
  * lock->owner state tracking:
@@ -331,7 +334,8 @@ static inline int lock_is_stealable(struct task_struct *pendowner, int unfair)
 	if (current->prio > pendowner->prio)
 		return 0;
 
-	if (!unfair && (current->prio == pendowner->prio))
+	if (unlikely(current->prio == pendowner->prio) &&
+	   !(unfair && rtmutex_lateral_steal))
 #endif
 		return 0;
 
@@ -355,7 +359,7 @@ static inline int try_to_steal_lock(struct rt_mutex *lock, int unfair)
 		return 1;
 
 	spin_lock(&pendowner->pi_lock);
-	if (!lock_is_stealable(pendowner, unfair)) {
+	if (!lock_is_stealable(pendowner, (unfair & rtmutex_lateral_steal))) {
 		spin_unlock(&pendowner->pi_lock);
 		return 0;
 	}
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 3465af2..c1a1c6d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -179,6 +179,10 @@ extern struct ctl_table inotify_table[];
 int sysctl_legacy_va_layout;
 #endif
 
+#ifdef CONFIG_RTLOCK_LATERAL_STEAL
+extern int rtmutex_lateral_steal;
+#endif
+
 extern int prove_locking;
 extern int lock_stat;
 
@@ -986,6 +990,16 @@ static struct ctl_table kern_table[] = {
 		.proc_handler   = &proc_dointvec,
        },
 #endif
+#ifdef CONFIG_RTLOCK_LATERAL_STEAL
+	{
+		.ctl_name       = CTL_UNNUMBERED,
+		.procname       = "rtmutex_lateral_steal",
+		.data           = &rtmutex_lateral_steal,
+		.maxlen         = sizeof(int),
+		.mode           = 0644,
+		.proc_handler   = &proc_dointvec,
+       },
+#endif
 #ifdef CONFIG_PROC_FS
 	{
 		.ctl_name       = CTL_UNNUMBERED,

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH [RT] 00/14] RFC - adaptive real-time locks, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 03/14] x86: FIFO ticket spinlocks, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 06/14] optimize rt lock wakeup, Gregory Haskins, (Thu Feb 21, 8:26 am)
[PATCH [RT] 07/14] adaptive real-time lock support, Gregory Haskins, (Thu Feb 21, 8:27 am)
[PATCH [RT] 09/14] adaptive mutexes, Gregory Haskins, (Thu Feb 21, 8:27 am)
[PATCH [RT] 10/14] adjust pi_lock usage in wakeup, Gregory Haskins, (Thu Feb 21, 8:27 am)
[PATCH [RT] 12/14] remove the extra call to try_to_take_lock, Gregory Haskins, (Thu Feb 21, 8:27 am)
[PATCH [RT] 14/14] sysctl for runtime-control of lateral m ..., Gregory Haskins, (Thu Feb 21, 8:27 am)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Gregory Haskins, (Thu Feb 21, 9:05 am)
Re: [PATCH [RT] 10/14] adjust pi_lock usage in wakeup, Steven Rostedt, (Thu Feb 21, 9:48 am)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Peter W. Morreale, (Thu Feb 21, 10:04 am)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Sven-Thorsten Dietrich, (Thu Feb 21, 10:06 am)
Re: [PATCH [RT] 10/14] adjust pi_lock usage in wakeup, Peter W. Morreale, (Thu Feb 21, 10:09 am)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Ingo Molnar, (Thu Feb 21, 2:24 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Bill Huey (hui), (Thu Feb 21, 2:33 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Gregory Haskins, (Thu Feb 21, 2:40 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Peter W. Morreale, (Thu Feb 21, 3:12 pm)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Peter W. Morreale, (Thu Feb 21, 3:42 pm)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Gregory Haskins, (Fri Feb 22, 6:29 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Steven Rostedt, (Fri Feb 22, 6:35 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Ingo Molnar, (Fri Feb 22, 6:35 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Peter Zijlstra, (Fri Feb 22, 6:40 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Steven Rostedt, (Fri Feb 22, 6:43 am)
Re: [PATCH [RT] 05/14] rearrange rt_spin_lock sleep, Steven Rostedt, (Fri Feb 22, 6:46 am)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Paul E. McKenney, (Fri Feb 22, 12:08 pm)
Re: [PATCH [RT] 07/14] adaptive real-time lock support, Pavel Machek, (Fri Feb 22, 12:14 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Paul E. McKenney, (Fri Feb 22, 12:43 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Sven-Thorsten Dietrich, (Fri Feb 22, 12:55 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Peter W. Morreale, (Fri Feb 22, 1:15 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Peter W. Morreale, (Fri Feb 22, 1:36 pm)
Re: [PATCH [RT] 08/14] add a loop counter based timeout me ..., Sven-Thorsten Dietrich, (Sat Feb 23, 12:36 am)
Re: [PATCH [RT] 00/14] RFC - adaptive real-time locks, Andrew Morton, (Sat Feb 23, 1:03 am)