Skip to contentSkip to conversation

rtmutex: Propagate priority setting into lock chains

PATCH In review Thomas Gleixner 4 participants 15 messages Jun 22, 2006 – Jun 24, 2006 Scheduler

lore
Share & tools
lore
#0 lore raw

cover rtmutex: Propagate priority setting into lock chains

Andrew,

Please add the following patches to the rtmutex / pi-futex patchset.

This ensures that asynchronous setscheduler() calls are properly propagated into a already blocked task's lock dependency chain.
The testsuite has also been improved to verify this behaviour.

tglx

--

#1 lore raw

PATCH 1/3 Drop tasklist lock in do_sched_setscheduler

There is no need to hold tasklist_lock across the setscheduler call, when we pin the task structure with get_task_struct(). Interrupts are disabled in setscheduler anyway and the permission checks do not need interrupts disabled.

 kernel/sched.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/sched.c +3 -1
Index: linux-2.6.17-mm/kernel/sched.c
===================================================================
@@ -4140,8 +4140,10 @@
 		read_unlock_irq(&tasklist_lock);
 		return -ESRCH;
 	}
-	retval = sched_setscheduler(p, policy, &lparam);
+	get_task_struct(p);
 	read_unlock_irq(&tasklist_lock);
+	retval = sched_setscheduler(p, policy, &lparam);
+	put_task_struct(p);
 	return retval;
 }
 

--

#2 lore raw

Re: [patch 1/3] Drop tasklist lock in do_sched_setscheduler

Quoted 17 lines · On Thu, 22 Jun 2006 09:08:38 -0000 Thomas Gleixner <[email protected]> wrote:

There is no need to hold tasklist_lock across the setscheduler call, when we pin the task structure with get_task_struct(). Interrupts are disabled in setscheduler anyway and the permission checks do not need interrupts disabled.

 kernel/sched.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6.17-mm/kernel/sched.c
===================================================================

kernel/sched.c +0 -0
@@ -4140,8 +4140,10 @@
 		read_unlock_irq(&tasklist_lock);

kernel/sched.c line 4149

Quoted 10 lines
kernel/sched.c +3 -1
 		return -ESRCH;
 	}
-	retval = sched_setscheduler(p, policy, &lparam);
+	get_task_struct(p);
 	read_unlock_irq(&tasklist_lock);
+	retval = sched_setscheduler(p, policy, &lparam);
+	put_task_struct(p);
 	return retval;
 }
 

Is this optimisation actually related to the rt-mutex patches, or to the other two patches?

#3 lore raw

Re: [patch 1/3] Drop tasklist lock in do_sched_setscheduler

Quoted 25 lines · Andrew Morton
Quoted 22 lines · On Thu, 22 Jun 2006 09:08:38 -0000 Thomas Gleixner <[email protected]> wrote:

There is no need to hold tasklist_lock across the setscheduler call, when we pin the task structure with get_task_struct(). Interrupts are disabled in setscheduler anyway and the permission checks do not need interrupts disabled.

 kernel/sched.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Index: linux-2.6.17-mm/kernel/sched.c
===================================================================

kernel/sched.c +1 -1
@@ -4140,8 +4140,10 @@
 		read_unlock_irq(&tasklist_lock);
 		return -ESRCH;
 	}
-	retval = sched_setscheduler(p, policy, &lparam);
+	get_task_struct(p);
 	read_unlock_irq(&tasklist_lock);
Quoted 8 lines

kernel/sched.c line 4149

Quoted 5 lines
kernel/sched.c +2 -0
+	retval = sched_setscheduler(p, policy, &lparam);
+	put_task_struct(p);
 	return retval;
 }
 

Is this optimisation actually related to the rt-mutex patches, or to the other two patches?

Yes. We neither want interrupt disabled nor holding tasklist lock when it comes to the lock chain walk. So its a preperatory patch and a general optimization.

tglx

#4 lore raw

Re: [patch 1/3] Drop tasklist lock in do_sched_setscheduler

In reply to Thomas Gleixner
Quoted 5 lines · On Thu, 22 Jun 2006 09:08:38 -0000 Thomas Gleixner <[email protected]> wrote:

There is no need to hold tasklist_lock across the setscheduler call, when we pin the task structure with get_task_struct(). Interrupts are disabled in setscheduler anyway and the permission checks do not need interrupts disabled.

These three patches had intricate dependencies upon the __IP__ and __IP_DECL__ gunk which later patches removed, so these patches do not compile against the pi-futex patches.

So I dropped these.

And I'll drop the lockdep patches, so you'll be able to redo these.

#5 lore raw

Re: [patch 1/3] Drop tasklist lock in do_sched_setscheduler

Quoted 7 lines · Andrew Morton

These three patches had intricate dependencies upon the __IP__ and __IP_DECL__ gunk which later patches removed, so these patches do not compile against the pi-futex patches.

So I dropped these.

And I'll drop the lockdep patches, so you'll be able to redo these.

Will do.

tglx

#6 lore raw

PATCH 2/3 rtmutex: Propagate priority settings into PI lock chains

In reply to Thomas Gleixner

When the priority of a task, which is blocked on a lock, changes we must propagate this change into the PI lock chain. Therefor the chain walk code is changed to get rid of the references to current to avoid false positives in the deadlock detector, as setscheduler might be called by a task which holds the lock on which the task whose priority is changed is blocked.
Also add some comments about the get/put_task_struct usage to avoid confusion.

 include/linux/sched.h |    2 ++
 kernel/rtmutex.c      |   41 ++++++++++++++++++++++++++++++++++++-----
 kernel/sched.c        |    2 ++
 3 files changed, 40 insertions(+), 5 deletions(-)
kernel/rtmutex.c +36 -5
Index: linux-2.6.17-mm/kernel/rtmutex.c
===================================================================
@@ -160,7 +160,8 @@
 static int rt_mutex_adjust_prio_chain(task_t *task,
 				      int deadlock_detect,
 				      struct rt_mutex *orig_lock,
-				      struct rt_mutex_waiter *orig_waiter)
+				      struct rt_mutex_waiter *orig_waiter,
+				      struct task_struct *top_task)
 {
 	struct rt_mutex *lock;
 	struct rt_mutex_waiter *waiter, *top_waiter = orig_waiter;
@@ -188,7 +189,7 @@
 			prev_max = max_lock_depth;
 			printk(KERN_WARNING "Maximum lock depth %d reached "
 			       "task: %s (%d)\n", max_lock_depth,
-			       current->comm, current->pid);
+			       top_task->comm, top_task->pid);
 		}
 		put_task_struct(task);
 
@@ -228,7 +229,7 @@
 	}
 
 	/* Deadlock detection */
-	if (lock == orig_lock || rt_mutex_owner(lock) == current) {
+	if (lock == orig_lock || rt_mutex_owner(lock) == top_task) {
 		debug_rt_mutex_deadlock(deadlock_detect, orig_waiter, lock);
 		spin_unlock(&lock->wait_lock);
 		ret = deadlock_detect ? -EDEADLK : 0;
@@ -431,6 +432,7 @@
 		__rt_mutex_adjust_prio(owner);
 		if (owner->pi_blocked_on) {
 			boost = 1;
+			/* gets dropped in rt_mutex_adjust_prio_chain()! */
 			get_task_struct(owner);
 		}
 		spin_unlock_irqrestore(&owner->pi_lock, flags);
@@ -439,6 +441,7 @@
 		spin_lock_irqsave(&owner->pi_lock, flags);
 		if (owner->pi_blocked_on) {
 			boost = 1;
+			/* gets dropped in rt_mutex_adjust_prio_chain()! */
 			get_task_struct(owner);
 		}
 		spin_unlock_irqrestore(&owner->pi_lock, flags);
@@ -448,7 +451,8 @@
 
 	spin_unlock(&lock->wait_lock);
 
-	res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock, waiter);
+	res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock, waiter,
+					 current);
 
 	spin_lock(&lock->wait_lock);
 
@@ -549,6 +553,7 @@
 
 		if (owner->pi_blocked_on) {
 			boost = 1;
+			/* gets dropped in rt_mutex_adjust_prio_chain()! */
 			get_task_struct(owner);
 		}
 		spin_unlock_irqrestore(&owner->pi_lock, flags);
@@ -561,12 +566,37 @@
 
 	spin_unlock(&lock->wait_lock);
 
-	rt_mutex_adjust_prio_chain(owner, 0, lock, NULL);
+	rt_mutex_adjust_prio_chain(owner, 0, lock, NULL, current);
 
 	spin_lock(&lock->wait_lock);
 }
 
 /*
+ * Recheck the pi chain, in case we got a priority setting
+ *
+ * Called from sched_setscheduler
+ */
+void rt_mutex_adjust_pi(struct task_struct *task)
+{
+	struct rt_mutex_waiter *waiter;
+	unsigned long flags;
+
+	spin_lock_irqsave(&task->pi_lock, flags);
+
+	waiter = task->pi_blocked_on;
+	if (!waiter || waiter->list_entry.prio == task->prio) {
+		spin_unlock_irqrestore(&task->pi_lock, flags);
+		return;
+	}
+
+	/* gets dropped in rt_mutex_adjust_prio_chain()! */
+	get_task_struct(task);
+	spin_unlock_irqrestore(&task->pi_lock, flags);
+
+	rt_mutex_adjust_prio_chain(task, 0, NULL, NULL, task);
+}
+
+/*
  * Slow path lock function:
  */
 static int __sched
@@ -633,6 +663,7 @@
 			if (unlikely(ret))
 				break;
 		}
+
 		spin_unlock(&lock->wait_lock);
 
 		debug_rt_mutex_print_deadlock(&waiter);
include/linux/sched.h +2 -0
Index: linux-2.6.17-mm/include/linux/sched.h
===================================================================
@@ -1125,11 +1125,13 @@
 #ifdef CONFIG_RT_MUTEXES
 extern int rt_mutex_getprio(task_t *p);
 extern void rt_mutex_setprio(task_t *p, int prio);
+extern void rt_mutex_adjust_pi(task_t *p);
 #else
 static inline int rt_mutex_getprio(task_t *p)
 {
 	return p->normal_prio;
 }
+# define rt_mutex_adjust_pi(p)		do { } while (0)
 #endif
 
 extern void set_user_nice(task_t *p, long nice);
kernel/sched.c +2 -0
Index: linux-2.6.17-mm/kernel/sched.c
===================================================================
@@ -4119,6 +4119,8 @@
 	__task_rq_unlock(rq);
 	spin_unlock_irqrestore(&p->pi_lock, flags);
 
+	rt_mutex_adjust_pi(p);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sched_setscheduler);

--

#7 lore raw

Re: [patch 2/3] rtmutex: Propagate priority settings into PI lock chains

I've stated these comments on the -rt thread, but it's more important to repeat them here.

Review

Quoted 13 lines · Thomas Gleixner

/*
+ * Recheck the pi chain, in case we got a priority setting
+ *
+ * Called from sched_setscheduler
+ */

(quoted diff) +8 -0
+void rt_mutex_adjust_pi(struct task_struct *task)
+{
+	struct rt_mutex_waiter *waiter;
+	unsigned long flags;
+
+	spin_lock_irqsave(&task->pi_lock, flags);
+
+	waiter = task->pi_blocked_on;

Good to see you fixed the waiter race that I mentioned in the other thread. You did it before I mentioned it, but I didn't read this yet ;)

Review

Quoted 10 lines
(quoted diff) +10 -0
+	if (!waiter || waiter->list_entry.prio == task->prio) {
+		spin_unlock_irqrestore(&task->pi_lock, flags);
+		return;
+	}
+
+	/* gets dropped in rt_mutex_adjust_prio_chain()! */
+	get_task_struct(task);
+	spin_unlock_irqrestore(&task->pi_lock, flags);
+
+	rt_mutex_adjust_prio_chain(task, 0, NULL, NULL, task);

The above means that you cant ever call sched_setscheduler from a interrupt handler (or softirq). The rt_mutex_adjust_prio_chain since that grabs wait_lock which is not for interrupt use.

Quoted 14 lines
(quoted diff) +4 -0
+}
+
+/*
  * Slow path lock function:
  */
 static int __sched
@@ -633,6 +663,7 @@
 			if (unlikely(ret))
 				break;
 		}
+
 		spin_unlock(&lock->wait_lock);
 
 		debug_rt_mutex_print_deadlock(&waiter);

[...]

kernel/sched.c

Quoted 6 lines

extern void set_user_nice(task_t *p, long nice);
Index: linux-2.6.17-mm/kernel/sched.c
===================================================================

kernel/sched.c +0 -0

Oh and Thomas...

export QUILT_DIFF_OPTS='-p'

kernel/sched.c

Quoted 1 line
kernel/sched.c +0 -0
@@ -4119,6 +4119,8 @@

Can sched_setscheduler be called from interrupt context?

kernel/sched.c line 4126

Quoted 8 lines
kernel/sched.c +2 -0
 	__task_rq_unlock(rq);
 	spin_unlock_irqrestore(&p->pi_lock, flags);
 
+	rt_mutex_adjust_pi(p);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sched_setscheduler);

I haven't found any place that this was called from interrupt context, but with this added, it can not be. So it should be documented that sched_setscheduler grabs locks that are not to be called from interrupt context.

-- Steve

kernel/sched.c +4 -0
Index: linux-2.6.17-rc4-mm1/kernel/sched.c
===================================================================
@@ -4006,6 +4006,10 @@ static void __setscheduler(struct task_s
  * @p: the task in question.
  * @policy: new policy.
  * @param: structure containing the new RT priority.
+ *
+ *  Do not call this from interrupt context.  If RT_MUTEXES is configured
+ *  then it can grab spin locks that are not protected with interrupts
+ *  disabled.
  */
 int sched_setscheduler(struct task_struct *p, int policy,
 		       struct sched_param *param)
#8 lore raw

Re: [patch 2/3] rtmutex: Propagate priority settings into PI lock chains

Quoted 23 lines · Steven Rostedt

I've stated these comments on the -rt thread, but it's more important to repeat them here.

Review

Quoted 13 lines · Thomas Gleixner

/*
+ * Recheck the pi chain, in case we got a priority setting
+ *
+ * Called from sched_setscheduler
+ */

(quoted diff) +8 -0
+void rt_mutex_adjust_pi(struct task_struct *task)
+{
+	struct rt_mutex_waiter *waiter;
+	unsigned long flags;
+
+	spin_lock_irqsave(&task->pi_lock, flags);
+
+	waiter = task->pi_blocked_on;

Good to see you fixed the waiter race that I mentioned in the other thread. You did it before I mentioned it, but I didn't read this yet ;)

Quoted 14 lines

Review

Quoted 10 lines
(quoted diff) +10 -0
+	if (!waiter || waiter->list_entry.prio == task->prio) {
+		spin_unlock_irqrestore(&task->pi_lock, flags);
+		return;
+	}
+
+	/* gets dropped in rt_mutex_adjust_prio_chain()! */
+	get_task_struct(task);
+	spin_unlock_irqrestore(&task->pi_lock, flags);
+
+	rt_mutex_adjust_prio_chain(task, 0, NULL, NULL, task);

The above means that you cant ever call sched_setscheduler from a interrupt handler (or softirq). The rt_mutex_adjust_prio_chain since that grabs wait_lock which is not for interrupt use.

Worse in RT context: It makes it unhealthy to call from a RT task as it doesn't have predictable runtime unless you know that the target task is not blocked on a deep locking tree.

I know this is very unlikely to happen very often in real life and this thread isn't about preempt-realtime, but I'll say it anyway: Hard realtime is about avoiding surprisingly long execution times - especially those which are extremely unlikely to happen, but nevertheless are possible, because you are not very likely to see those situations in any tests, and therefore you can suddenly miss deadlines in the field without a clue what is happening.

Esben

Quoted 72 lines
Quoted 15 lines
(quoted diff) +4 -0
+}
+
+/*
  * Slow path lock function:
  */
 static int __sched
@@ -633,6 +663,7 @@
 			if (unlikely(ret))
 				break;
 		}
+
 		spin_unlock(&lock->wait_lock);
 
 		debug_rt_mutex_print_deadlock(&waiter);

[...]

kernel/sched.c

Quoted 6 lines

extern void set_user_nice(task_t *p, long nice);
Index: linux-2.6.17-mm/kernel/sched.c
===================================================================

kernel/sched.c +0 -0

Oh and Thomas...

export QUILT_DIFF_OPTS='-p'

kernel/sched.c

Quoted 1 line
kernel/sched.c +0 -0
@@ -4119,6 +4119,8 @@

Can sched_setscheduler be called from interrupt context?

kernel/sched.c line 4126

Quoted 8 lines
kernel/sched.c +2 -0
 	__task_rq_unlock(rq);
 	spin_unlock_irqrestore(&p->pi_lock, flags);
 
+	rt_mutex_adjust_pi(p);
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sched_setscheduler);

I haven't found any place that this was called from interrupt context, but with this added, it can not be. So it should be documented that sched_setscheduler grabs locks that are not to be called from interrupt context.

-- Steve

Index: linux-2.6.17-rc4-mm1/kernel/sched.c
===================================================================

kernel/sched.c +4 -1
@@ -4006,6 +4006,10 @@ static void __setscheduler(struct task_s
 * @p: the task in question.
 * @policy: new policy.
 * @param: structure containing the new RT priority.
+ *
+ *  Do not call this from interrupt context.  If RT_MUTEXES is configured
+ *  then it can grab spin locks that are not protected with interrupts
+ *  disabled.
 */
 int sched_setscheduler(struct task_struct *p, int policy,
 		       struct sched_param *param)
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw

Re: [patch 2/3] rtmutex: Propagate priority settings into PI lock chains

Quoted 10 lines · Esben Nielsen
Quoted 3 lines

The above means that you cant ever call sched_setscheduler from a interrupt handler (or softirq). The rt_mutex_adjust_prio_chain since that grabs wait_lock which is not for interrupt use.

Worse in RT context: It makes it unhealthy to call from a RT task as it doesn't have predictable runtime unless you know that the target task is not blocked on a deep locking tree.

I know this is very unlikely to happen very often in real life and this thread isn't about preempt-realtime, but I'll say it anyway: Hard realtime

Esben, you are right. This is not about RT so it does _not_ belong in this thread. Please keep the topic in this thread about -mm. We already have a RT thread to discuss this in.

My comments here where about a fact that setscheduler when from interrupt context friendly to interrupt context unfriendly and I thought it would be good to document that fact. I like Andrews answer better. Document it with a BUG_ON(in_interrupt).

-- Steve

Quoted 6 lines

is about avoiding surprisingly long execution times - especially those which are extremely unlikely to happen, but nevertheless are possible, because you are not very likely to see those situations in any tests, and therefore you can suddenly miss deadlines in the field without a clue what is happening.

#10 lore raw

Re: [patch 2/3] rtmutex: Propagate priority settings into PI lock chains

In reply to Steven Rostedt
Quoted 6 lines · On Thu, 22 Jun 2006 10:20:59 -0400 (EDT) Steven Rostedt <[email protected]>…
Quoted 6 lines
(quoted diff) +6 -0
+	if (!waiter || waiter->list_entry.prio == task->prio) {
+		spin_unlock_irqrestore(&task->pi_lock, flags);
+		return;
+	}
+
+	/* gets dropped in rt_mutex_adjust_prio_chain()! */
Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+	get_task_struct(task);
+	spin_unlock_irqrestore(&task->pi_lock, flags);
+
+	rt_mutex_adjust_prio_chain(task, 0, NULL, NULL, task);

The above means that you cant ever call sched_setscheduler from a interrupt handler (or softirq). The rt_mutex_adjust_prio_chain since that grabs wait_lock which is not for interrupt use.

Running setscheduler() from IRQ context sounds rather perverse. BUG_ON(in_interrupt()) would reduce the temptation.

#11 lore raw

PATCH 1/1 bug if setscheduler is called from interrupt context.

Thomas Gleixner is adding the call to a rtmutex function in setscheduler. This call grabs a spin_lock that is not always protected by interrupts disabled. So this means that setscheduler cant be called from interrupt context.

To prevent this from happening in the future, this patch adds a BUG_ON(in_interrupt()) in that function. (Thanks to akpm <aka. Andrew Morton> for this suggestion).

-- Steve

kernel/sched.c +2 -0
Index: linux-2.6.17-mm1/kernel/sched.c
===================================================================
@@ -4034,6 +4034,8 @@ int sched_setscheduler(struct task_struc
 	unsigned long flags;
 	runqueue_t *rq;
 
+	/* may grab non-irq protected spin_locks */
+	BUG_ON(in_interrupt());
 recheck:
 	/* double check policy once rq lock held */
 	if (policy < 0)
#12 lore raw

Re: [patch 2/3] rtmutex: Propagate priority settings into PI lock chains

In reply to Thomas Gleixner
Quoted 9 lines · On Thu, 22 Jun 2006 09:08:39 -0000 Thomas Gleixner <[email protected]> wrote:

When the priority of a task, which is blocked on a lock, changes we must propagate this change into the PI lock chain. Therefor the chain walk code is changed to get rid of the references to current to avoid false positives in the deadlock detector, as setscheduler might be called by a task which holds the lock on which the task whose priority is changed is blocked.
Also add some comments about the get/put_task_struct usage to avoid confusion.

Quoted 5 lines
 include/linux/sched.h |    2 ++
 kernel/rtmutex.c      |   41 ++++++++++++++++++++++++++++++++++++-----

That file's full of lockdep droppings from a different patchset. Please check the end result.

#13 lore raw

Re: [patch 2/3] rtmutex: Propagate priority settings into PI lock chains

Quoted 12 lines · Andrew Morton
Quoted 9 lines · On Thu, 22 Jun 2006 09:08:39 -0000 Thomas Gleixner <[email protected]> wrote:

When the priority of a task, which is blocked on a lock, changes we must propagate this change into the PI lock chain. Therefor the chain walk code is changed to get rid of the references to current to avoid false positives in the deadlock detector, as setscheduler might be called by a task which holds the lock on which the task whose priority is changed is blocked.
Also add some comments about the get/put_task_struct usage to avoid confusion.

Quoted 8 lines
Quoted 5 lines
 include/linux/sched.h |    2 ++
 kernel/rtmutex.c      |   41 ++++++++++++++++++++++++++++++++++++-----

That file's full of lockdep droppings from a different patchset. Please check the end result.

Will do in a minute

tglx

#14 lore raw

PATCH 3/3 rtmutex: Modify rtmutex-tester to test the setscheduler propagation

In reply to Thomas Gleixner

Make test suite setscheduler calls asynchronously. Remove the waits in the test cases and add a new testcase to verify the correctness of the setscheduler priority propagation.

 kernel/rtmutex-tester.c                               |   32 +--
 scripts/rt-tester/check-all.sh                        |    1 
 scripts/rt-tester/t2-l1-2rt-sameprio.tst              |    2 
 scripts/rt-tester/t2-l1-pi.tst                        |    2 
 scripts/rt-tester/t2-l1-signal.tst                    |    2 
 scripts/rt-tester/t2-l2-2rt-deadlock.tst              |    2 
 scripts/rt-tester/t3-l1-pi-1rt.tst                    |    3 
 scripts/rt-tester/t3-l1-pi-2rt.tst                    |    3 
 scripts/rt-tester/t3-l1-pi-3rt.tst                    |    3 
 scripts/rt-tester/t3-l1-pi-signal.tst                 |    3 
 scripts/rt-tester/t3-l1-pi-steal.tst                  |    3 
 scripts/rt-tester/t3-l2-pi.tst                        |    3 
 scripts/rt-tester/t4-l2-pi-deboost.tst                |    4 
 scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst |  183 ++++++++++++++++++
 scripts/rt-tester/t5-l4-pi-boost-deboost.tst          |    5 
 15 files changed, 202 insertions(+), 49 deletions(-)
scripts/rt-tester/check-all.sh +1 -0
Index: linux-2.6.17-mm/scripts/rt-tester/check-all.sh
===================================================================
@@ -18,4 +18,5 @@
 testit t3-l2-pi.tst
 testit t4-l2-pi-deboost.tst
 testit t5-l4-pi-boost-deboost.tst
+testit t5-l4-pi-boost-deboost-setsched.tst
 
kernel/rtmutex-tester.c +18 -14
Index: linux-2.6.17-mm/kernel/rtmutex-tester.c
===================================================================
@@ -46,7 +46,7 @@
 	RTTEST_LOCKINTNOWAIT,	/* 6 Lock interruptible no wait in wakeup, data = lockindex */
 	RTTEST_LOCKCONT,	/* 7 Continue locking after the wakeup delay */
 	RTTEST_UNLOCK,		/* 8 Unlock, data = lockindex */
-	RTTEST_LOCKBKL, 	/* 9 Lock BKL */
+	RTTEST_LOCKBKL,		/* 9 Lock BKL */
 	RTTEST_UNLOCKBKL,	/* 10 Unlock BKL */
 	RTTEST_SIGNAL,		/* 11 Signal other test thread, data = thread id */
 	RTTEST_RESETEVENT = 98,	/* 98 Reset event counter */
@@ -55,7 +55,6 @@
 
 static int handle_op(struct test_thread_data *td, int lockwakeup)
 {
-	struct sched_param schedpar;
 	int i, id, ret = -EINVAL;
 
 	switch(td->opcode) {
@@ -63,17 +62,6 @@
 	case RTTEST_NOP:
 		return 0;
 
-	case RTTEST_SCHEDOT:
-		schedpar.sched_priority = 0;
-		ret = sched_setscheduler(current, SCHED_NORMAL, &schedpar);
-		if (!ret)
-			set_user_nice(current, 0);
-		return ret;
-
-	case RTTEST_SCHEDRT:
-		schedpar.sched_priority = td->opdata;
-		return sched_setscheduler(current, SCHED_FIFO, &schedpar);
-
 	case RTTEST_LOCKCONT:
 		td->mutexes[td->opdata] = 1;
 		td->event = atomic_add_return(1, &rttest_event);
@@ -310,9 +298,10 @@
 static ssize_t sysfs_test_command(struct sys_device *dev, const char *buf,
 				  size_t count)
 {
+	struct sched_param schedpar;
 	struct test_thread_data *td;
 	char cmdbuf[32];
-	int op, dat, tid;
+	int op, dat, tid, ret;
 
 	td = container_of(dev, struct test_thread_data, sysdev);
 	tid = td->sysdev.id;
@@ -334,6 +323,21 @@
 		return -EINVAL;
 
 	switch (op) {
+	case RTTEST_SCHEDOT:
+		schedpar.sched_priority = 0;
+		ret = sched_setscheduler(threads[tid], SCHED_NORMAL, &schedpar);
+		if (ret)
+			return ret;
+		set_user_nice(current, 0);
+		break;
+
+	case RTTEST_SCHEDRT:
+		schedpar.sched_priority = dat;
+		ret = sched_setscheduler(threads[tid], SCHED_FIFO, &schedpar);
+		if (ret)
+			return ret;
+		break;
+
 	case RTTEST_SIGNAL:
 		send_sig(SIGHUP, threads[tid], 0);
 		break;
scripts/rt-tester/t2-l1-2rt-sameprio.tst +0 -2
Index: linux-2.6.17-mm/scripts/rt-tester/t2-l1-2rt-sameprio.tst
===================================================================
@@ -57,9 +57,7 @@
 
 # Set schedulers
 C: schedfifo:		0: 	80
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	80
-W: opcodeeq:		1: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t2-l1-pi.tst +0 -2
Index: linux-2.6.17-mm/scripts/rt-tester/t2-l1-pi.tst
===================================================================
@@ -57,9 +57,7 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	80
-W: opcodeeq:		1: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t2-l1-signal.tst +0 -2
Index: linux-2.6.17-mm/scripts/rt-tester/t2-l1-signal.tst
===================================================================
@@ -57,9 +57,7 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedother:		1: 	0
-W: opcodeeq:		1: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t2-l2-2rt-deadlock.tst +0 -2
Index: linux-2.6.17-mm/scripts/rt-tester/t2-l2-2rt-deadlock.tst
===================================================================
@@ -57,9 +57,7 @@
 
 # Set schedulers
 C: schedfifo:		0: 	80
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	80
-W: opcodeeq:		1: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t3-l1-pi-1rt.tst +0 -3
Index: linux-2.6.17-mm/scripts/rt-tester/t3-l1-pi-1rt.tst
===================================================================
@@ -57,11 +57,8 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedother:		1: 	0
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	82
-W: opcodeeq:		2: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t3-l1-pi-2rt.tst +0 -3
Index: linux-2.6.17-mm/scripts/rt-tester/t3-l1-pi-2rt.tst
===================================================================
@@ -57,11 +57,8 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	81
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	82
-W: opcodeeq:		2: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t3-l1-pi-3rt.tst +0 -3
Index: linux-2.6.17-mm/scripts/rt-tester/t3-l1-pi-3rt.tst
===================================================================
@@ -57,11 +57,8 @@
 
 # Set schedulers
 C: schedfifo:		0: 	80
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	81
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	82
-W: opcodeeq:		2: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t3-l1-pi-signal.tst +0 -3
Index: linux-2.6.17-mm/scripts/rt-tester/t3-l1-pi-signal.tst
===================================================================
@@ -55,11 +55,8 @@
 
 # Set priorities
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	80
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	81
-W: opcodeeq:		2: 	0
 
 # T0 lock L0
 C: lock:		0:	0
scripts/rt-tester/t3-l1-pi-steal.tst +0 -3
Index: linux-2.6.17-mm/scripts/rt-tester/t3-l1-pi-steal.tst
===================================================================
@@ -57,11 +57,8 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	80
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	81
-W: opcodeeq:		2: 	0
 
 # T0 lock L0
 C: lock:		0: 	0
scripts/rt-tester/t3-l2-pi.tst +0 -3
Index: linux-2.6.17-mm/scripts/rt-tester/t3-l2-pi.tst
===================================================================
@@ -57,11 +57,8 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedother:		1: 	0
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	82
-W: opcodeeq:		2: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t4-l2-pi-deboost.tst +0 -4
Index: linux-2.6.17-mm/scripts/rt-tester/t4-l2-pi-deboost.tst
===================================================================
@@ -57,13 +57,9 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedother:		1: 	0
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	82
-W: opcodeeq:		2: 	0
 C: schedfifo:		3: 	83
-W: opcodeeq:		3: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0
scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst new file +183 -0

183 lines not on this page · raw message

scripts/rt-tester/t5-l4-pi-boost-deboost.tst +0 -5
Index: linux-2.6.17-mm/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
===================================================================
@@ -57,15 +57,10 @@
 
 # Set schedulers
 C: schedother:		0: 	0
-W: opcodeeq:		0: 	0
 C: schedfifo:		1: 	81
-W: opcodeeq:		1: 	0
 C: schedfifo:		2: 	82
-W: opcodeeq:		2: 	0
 C: schedfifo:		3: 	83
-W: opcodeeq:		3: 	0
 C: schedfifo:		4: 	84
-W: opcodeeq:		4: 	0
 
 # T0 lock L0
 C: locknowait:		0: 	0

--