Skip to contentSkip to conversation

Fix timeout bug in rtmutex in 2.6.18-rt

PATCH In review Esben Nielsen 2 participants 10 messages Oct 1, 2006 – Nov 13, 2006 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20061001112829.630288000@frodo

#1 lore raw

PATCH 1/5 Fix timeout bug in rtmutex in 2.6.18-rt

This patch adds a new interface to the scheduler: A task can be scheduled in LIFO order for a while instead of the usual FIFO order. This is more or less equivalent to raising it's priority by 1/2.

This property is now needed by the rtmutexes to solve the last few issues, but I can imagine it can be usefull for other subsystems too.

 include/linux/init_task.h |    1
 include/linux/sched.h     |   62 ++++++++++++++++++++++++++++++++++++++++++++++
 kernel/sched.c            |   29 +++++++++++++++++----
 3 files changed, 87 insertions(+), 5 deletions(-)
include/linux/init_task.h +1 -0
Index: linux-2.6.18-rt/include/linux/init_task.h
===================================================================
@@ -91,6 +91,7 @@ extern struct group_info init_groups;
 	.prio		= MAX_PRIO-20,					\
 	.static_prio	= MAX_PRIO-20,					\
 	.normal_prio	= MAX_PRIO-20,					\
+	.sched_lifo	= 0,						\
 	.policy		= SCHED_NORMAL,					\
 	.cpus_allowed	= CPU_MASK_ALL,					\
 	.mm		= NULL,						\
include/linux/sched.h +62 -0

74 lines not on this page · raw message

kernel/sched.c +24 -5
Index: linux-2.6.18-rt/kernel/sched.c
===================================================================
@@ -164,8 +164,8 @@
 	(JIFFIES_TO_NS(MAX_SLEEP_AVG * \
 		(MAX_BONUS / 2 + DELTA((p)) + 1) / MAX_BONUS - 1))
 
-#define TASK_PREEMPTS_CURR(p, rq) \
-	((p)->prio < (rq)->curr->prio)
+#define TASK_PREEMPTS(p,q) task_preempts(p,q)
+#define TASK_PREEMPTS_CURR(p, rq)	TASK_PREEMPTS(p,(rq)->curr)
 
 /*
  * task_timeslice() scales user-nice values [ -20 ... 0 ... 19 ]
@@ -707,6 +707,17 @@ sched_info_switch(struct task_struct *pr
 #define sched_info_switch(t, next)	do { } while (0)
 #endif /* CONFIG_SCHEDSTATS || CONFIG_TASK_DELAY_ACCT */
 
+int task_preempts(struct task_struct *p, struct task_struct *q)
+{
+	if (p->prio < q->prio)
+		return 1;
+
+	if (p->prio > q->prio)
+		return 0;
+
+	return p->sched_lifo;
+}
+
 #if defined(CONFIG_PREEMPT_RT) && defined(CONFIG_SMP)
 static __cacheline_aligned_in_smp atomic_t rt_overload;
 #endif
@@ -770,7 +781,12 @@ static void enqueue_task(struct task_str
 {
 	WARN_ON_ONCE(p->flags & PF_DEAD);
 	sched_info_queued(p);
-	list_add_tail(&p->run_list, array->queue + p->prio);
+
+	if (p->sched_lifo)
+		list_add(&p->run_list, array->queue + p->prio);
+	else
+		list_add_tail(&p->run_list, array->queue + p->prio);
+
 	__set_bit(p->prio, array->bitmap);
 	array->nr_active++;
 	p->array = array;
@@ -783,7 +799,10 @@ static void enqueue_task(struct task_str
  */
 static void requeue_task(struct task_struct *p, struct prio_array *array)
 {
-	list_move_tail(&p->run_list, array->queue + p->prio);
+	if (p->sched_lifo)
+		list_move(&p->run_list, array->queue + p->prio);
+	else
+		list_move_tail(&p->run_list, array->queue + p->prio);
 }
 
 static inline void
@@ -1463,7 +1482,7 @@ static void balance_rt_tasks(struct rq *
 		 * Do we have an RT task that preempts
 		 * the to-be-scheduled task?
 		 */
-		if (p && (p->prio < next->prio)) {
+		if (p && TASK_PREEMPTS(p,next)) {
 			WARN_ON(p == src_rq->curr);
 			WARN_ON(!p->array);
 			schedstat_inc(this_rq, rto_pulled);

--

#2 lore raw
Quoted 3 lines · Esben Nielsen
 include/linux/init_task.h |    1
 include/linux/sched.h     |   62 
 kernel/sched.c            |   29 +++++++++++++++++----

what kernel tree is this supposed to be against? Neither vanilla nor -rt7 2.6.18 works:

Hunk #1 FAILED at 91.
1 out of 1 hunk FAILED -- rejects in file include/linux/init_task.h patching file include/linux/sched.h
Hunk #1 FAILED at 928.
Hunk #2 FAILED at 1330.
2 out of 2 hunks FAILED -- rejects in file include/linux/sched.h patching file kernel/sched.c
Hunk #1 succeeded at 157 with fuzz 2 (offset -7 lines). Hunk #2 FAILED at 700.
Hunk #3 FAILED at 774.
Hunk #4 FAILED at 792.
Hunk #5 FAILED at 1475.
4 out of 5 hunks FAILED -- rejects in file kernel/sched.c

Ingo

#3 lore raw
Quoted 9 lines · Ingo Molnar
Quoted 3 lines · Esben Nielsen
 include/linux/init_task.h |    1
 include/linux/sched.h     |   62 
 kernel/sched.c            |   29 +++++++++++++++++----

what kernel tree is this supposed to be against? Neither vanilla nor -rt7 2.6.18 works:

ah, whitespace damage ... every line in the patch has an extra space character in front of it.

Ingo

#4 lore raw

on SMP i had to remove this assert:

kernel/rtmutex.c +1 -1
Index: linux/kernel/rtmutex.c
===================================================================
@@ -823,7 +823,7 @@ rt_spin_lock_slowunlock(struct rt_mutex 
 	}
 	wakeup_next_waiter(lock, 1);
 	spin_unlock_irqrestore(&lock->wait_lock, flags);
-	BUG_ON(current->boosting_prio != MAX_PRIO);
+//	BUG_ON(current->boosting_prio != MAX_PRIO);
 	/* Undo pi boosting.when necessary */
 	rt_mutex_adjust_prio(current);
 }

because it triggered almost immediately after bootup.

Ingo

#5 lore raw
Quoted 17 lines · Ingo Molnar

on SMP i had to remove this assert:

Index: linux/kernel/rtmutex.c
===================================================================

kernel/rtmutex.c +1 -1
@@ -823,7 +823,7 @@ rt_spin_lock_slowunlock(struct rt_mutex
 	}
 	wakeup_next_waiter(lock, 1);
 	spin_unlock_irqrestore(&lock->wait_lock, flags);
-	BUG_ON(current->boosting_prio != MAX_PRIO);
+//	BUG_ON(current->boosting_prio != MAX_PRIO);
 	/* Undo pi boosting.when necessary */
 	rt_mutex_adjust_prio(current);
 }
Quoted 2 lines

because it triggered almost immediately after bootup.

Hmm, boosting_prio should be MAX_PRIO at that point. boosting_prio should
only be different from MAX_PRIO while a task is trying to lock a mutex - i.e. while it is in a *_slowlock() function.

On which kernel have you applied the patch?

I am looking at 2.6.18-rt6 and trying to see if there is a race conditions.
I can't see it that easily (or I would probably have seen it already :-). task->boosting_prio is not set when task->pi_lock is not taken. And then it is only set to something else than MAX_PRIO if task->pi_blocked_on is set.

Quoted 2 lines

Ingo

Esben

#6 lore raw
In reply to Ingo Molnar
Quoted 9 lines · Ingo Molnar
Quoted 3 lines · Esben Nielsen
 include/linux/init_task.h |    1
 include/linux/sched.h     |   62
 kernel/sched.c            |   29 +++++++++++++++++----

what kernel tree is this supposed to be against? Neither vanilla nor -rt7 2.6.18 works:

Sorry, I missed the exact number. I believe it was 2.6.18-rt5 or 2.6.18-rt6. I know it wasn't -rt7 because Thomas changed the locking..

Esben

Quoted 17 lines

Hunk #1 FAILED at 91.
1 out of 1 hunk FAILED -- rejects in file include/linux/init_task.h patching file include/linux/sched.h
Hunk #1 FAILED at 928.
Hunk #2 FAILED at 1330.
2 out of 2 hunks FAILED -- rejects in file include/linux/sched.h patching file kernel/sched.c
Hunk #1 succeeded at 157 with fuzz 2 (offset -7 lines). Hunk #2 FAILED at 700.
Hunk #3 FAILED at 774.
Hunk #4 FAILED at 792.
Hunk #5 FAILED at 1475.
4 out of 5 hunks FAILED -- rejects in file kernel/sched.c

Ingo

#7 lore raw

PATCH 2/5 Fix timeout bug in rtmutex in 2.6.18-rt

In reply to a message not in the archive

A minor update to the rt-mutex tester framework.

 scripts/rt-tester/reset-tester.py            |   18 ++++++++++++++++++
 scripts/rt-tester/t2-l1-signal.tst           |    3 +++
 scripts/rt-tester/t3-l1-pi-signal.tst        |    3 ++-
 scripts/rt-tester/t4-l2-pi-deboost.tst       |    2 ++
 scripts/rt-tester/t5-l4-pi-boost-deboost.tst |    2 ++
 5 files changed, 27 insertions(+), 1 deletion(-)
scripts/rt-tester/reset-tester.py new file +18 -0
Index: linux-2.6.18-rt/scripts/rt-tester/reset-tester.py
===================================================================
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+
+sysfsprefix = "/sys/devices/system/rttest/rttest"
+statusfile = "/status"
+commandfile = "/command"
+
+for i in range(0,8):
+    cmdstr = "%s:%s" %("99", "0")
+    fname = "%s%d%s" %(sysfsprefix, i, commandfile)
+
+    try:
+        fcmd = open(fname, 'w')
+        fcmd.write(cmdstr)
+        fcmd.close()
+    except Exception,ex:
+        print i
+        print ex
+
scripts/rt-tester/t2-l1-signal.tst +3 -0
Index: linux-2.6.18-rt/scripts/rt-tester/t2-l1-signal.tst
===================================================================
@@ -75,3 +75,6 @@ T: opcodeeq:		1:	-4
 # Unlock and exit
 C: unlock:		0: 	0
 W: unlocked:		0: 	0
+
+# Reset the -4 opcode from the signal
+C: reset:               1:      0
\ No newline at end of file
scripts/rt-tester/t3-l1-pi-signal.tst +2 -1
Index: linux-2.6.18-rt/scripts/rt-tester/t3-l1-pi-signal.tst
===================================================================
@@ -95,4 +95,5 @@ C: unlock:		1: 	0
 W: unlocked:		1: 	0
 
 
-
+# Reset the -4 opcode from the signal
+C: reset:               2:      0
\ No newline at end of file
scripts/rt-tester/t4-l2-pi-deboost.tst +2 -0
Index: linux-2.6.18-rt/scripts/rt-tester/t4-l2-pi-deboost.tst
===================================================================
@@ -121,3 +121,5 @@ W: unlocked:		2:	1
 C: unlock:		0:	0
 W: unlocked:		0:	0
 
+# Reset the -4 opcode from the signal
+C: reset:               3:      0
\ No newline at end of file
scripts/rt-tester/t5-l4-pi-boost-deboost.tst +2 -0
Index: linux-2.6.18-rt/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
===================================================================
@@ -141,3 +141,5 @@ W: unlocked:		2:	2
 W: unlocked:		1:	1
 W: unlocked:		0:	0
 
+# Reset the -4 opcode from the signal
+C: reset:               4:      0
\ No newline at end of file

--

#8 lore raw

PATCH 3/5 Fix timeout bug in rtmutex in 2.6.18-rt

In reply to a message not in the archive

This patch fixes

1) The timeout bug in rtmutexes and PI futexes: When a task is blocked on a lock with timeout and times out it will not wakeup until the owner of the lock is done. This is because the owner is boosted to the same priority as the blocked task and therefore has the CPU such the blocked task never gets around to de-boost it!

2) setscheduler() now does the PI walking - but defers the work to the blocked task.

3) In general it makes sure that a task, which is boosting another has enough
priority to do the de-boosting no matter how complicated the lock structure is, or how many times the priorities have changed.

The idea behind the patch is simple:
If a task is boosting another it is scheduled in LIFO order and it will never loose it's priority. This property lasts until it has left the lock operation (successfully or not).

The needed priority to do the unboosting is stored in task->boosting_prio. In the current patch this is always increasing (numerically decreasing) while trying to take a lock. In a future it might be found safe to decrease boosting_prio before finally leaving the lock operation.

 include/linux/rtmutex.h                               |    1
 include/linux/sched.h                                 |    6
 kernel/fork.c                                         |    1
 kernel/rtmutex.c                                      |  142 ++++++++++++------
 kernel/rtmutex_common.h                               |    1
 kernel/sched.c                                        |   21 ++
 scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst |   36 ++--
 scripts/rt-tester/t5-l4-pi-boost-deboost.tst          |   12 -
 8 files changed, 156 insertions(+), 64 deletions(-)
include/linux/rtmutex.h +1 -0
Index: linux-2.6.18-rt/include/linux/rtmutex.h
===================================================================
@@ -99,6 +99,7 @@ extern void rt_mutex_unlock(struct rt_mu
 #ifdef CONFIG_RT_MUTEXES
 # define INIT_RT_MUTEXES(tsk)						\
 	.pi_waiters	= PLIST_HEAD_INIT(tsk.pi_waiters, tsk.pi_lock),	\
+	.boosting_prio	= MAX_PRIO,					\
 	INIT_RT_MUTEX_DEBUG(tsk)
 #else
 # define INIT_RT_MUTEXES(tsk)
include/linux/sched.h +6 -0
Index: linux-2.6.18-rt/include/linux/sched.h
===================================================================
@@ -1069,6 +1069,12 @@ struct task_struct {
 	struct plist_head pi_waiters;
 	/* Deadlock detection and priority inheritance handling */
 	struct rt_mutex_waiter *pi_blocked_on;
+
+	/*
+	 * Priority to which this task is boosting something. Don't lower the
+	 * priority below this before the boosting is resolved;
+	 */
+	int boosting_prio;
 #endif
 
 #ifdef CONFIG_DEBUG_MUTEXES
kernel/fork.c +1 -0
Index: linux-2.6.18-rt/kernel/fork.c
===================================================================
@@ -966,6 +966,7 @@ static inline void rt_mutex_init_task(st
 	spin_lock_init(&p->pi_lock);
 	plist_head_init(&p->pi_waiters, &p->pi_lock);
 	p->pi_blocked_on = NULL;
+	p->boosting_prio = MAX_PRIO;
 # ifdef CONFIG_DEBUG_RT_MUTEXES
 	p->last_kernel_lock = NULL;
 # endif
kernel/rtmutex.c +102 -40

328 lines not on this page · raw message

kernel/rtmutex_common.h +1 -0
Index: linux-2.6.18-rt/kernel/rtmutex_common.h
===================================================================
@@ -49,6 +49,7 @@ struct rt_mutex_waiter {
 	struct plist_node	pi_list_entry;
 	struct task_struct	*task;
 	struct rt_mutex		*lock;
+	int			old_sched_lifo;
 #ifdef CONFIG_DEBUG_RT_MUTEXES
 	unsigned long		ip;
 	pid_t			deadlock_task_pid;
kernel/sched.c +16 -5
Index: linux-2.6.18-rt/kernel/sched.c
===================================================================
@@ -4654,9 +4654,15 @@ void set_thread_priority(struct task_str
 			resched_task(rq->curr);
 	}
 	__task_rq_unlock(rq);
-	spin_unlock_irqrestore(&p->pi_lock, flags);
 
-	rt_mutex_adjust_pi(p);
+	/*
+	 * If the process is blocked on rt-mutex, it will now wake up and
+	 * reinsert itself into the wait list and boost the owner correctly
+	 */
+	if (p->pi_blocked_on)
+		wake_up_process_mutex(p);
+
+	spin_unlock_irqrestore(&p->pi_lock, flags);
 }
 
 /**
@@ -4759,9 +4765,15 @@ recheck:
 			resched_task(rq->curr);
 	}
 	__task_rq_unlock(rq);
-	spin_unlock_irqrestore(&p->pi_lock, flags);
 
-	rt_mutex_adjust_pi(p);
+	/*
+	 * If the process is blocked on rt-mutex, it will now wake up and
+	 * reinsert itself into the wait list and boost the owner correctly
+	 */
+	if (p->pi_blocked_on)
+		wake_up_process_mutex(p);
+
+	spin_unlock_irqrestore(&p->pi_lock, flags);
 
 	return 0;
 }
@@ -7627,4 +7639,3 @@ void notrace preempt_enable_no_resched(v
 
 EXPORT_SYMBOL(preempt_enable_no_resched);
 #endif
-
scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst +23 -13
Index: linux-2.6.18-rt/scripts/rt-tester/t5-l4-pi-boost-deboost-setsched.tst
===================================================================
@@ -107,10 +107,10 @@ T: prioeq:		3:	84
 # Reduce prio of T4
 C: schedfifo:		4: 	80
 T: prioeq:		0: 	83
-T: prioeq:		1:	83
-T: prioeq:		2:	83
-T: prioeq:		3:	83
-T: prioeq:		4:	80
+T: prioeq:		1:	84
+T: prioeq:		2:	84
+T: prioeq:		3:	84
+T: prioeq:		4:	84
 
 # Increase prio of T4
 C: schedfifo:		4: 	84
@@ -139,36 +139,46 @@ T: prioeq:		4:	84
 # Reduce prio of T3
 C: schedfifo:		3: 	83
 T: prioeq:		0: 	84
-T: prioeq:		1:	84
-T: prioeq:		2:	84
-T: prioeq:		3:	84
+T: prioeq:		1:	85
+T: prioeq:		2:	85
+T: prioeq:		3:	85
 T: prioeq:		4:	84
 
 # Signal T4
 C: signal:		4: 	0
 W: unlocked:		4: 	3
 T: prioeq:		0: 	83
-T: prioeq:		1:	83
-T: prioeq:		2:	83
-T: prioeq:		3:	83
+T: prioeq:		1:	85
+T: prioeq:		2:	85
+T: prioeq:		3:	85
+T: prioeq:		4:	84
 
 # Signal T3
 C: signal:		3: 	0
 W: unlocked:		3: 	2
 T: prioeq:		0: 	82
-T: prioeq:		1:	82
-T: prioeq:		2:	82
+T: prioeq:		1:	85
+T: prioeq:		2:	85
+T: prioeq:		3:	83
+T: prioeq:		4:	84
 
 # Signal T2
 C: signal:		2: 	0
 W: unlocked:		2: 	1
 T: prioeq:		0: 	81
-T: prioeq:		1:	81
+T: prioeq:		1:	85
+T: prioeq:		2:	82
+T: prioeq:		3:	83
+T: prioeq:		4:	84
 
 # Signal T1
 C: signal:		1: 	0
 W: unlocked:		1: 	0
 T: priolt:		0: 	1
+T: prioeq:		1:	81
+T: prioeq:		2:	82
+T: prioeq:		3:	83
+T: prioeq:		4:	84
 
 # Unlock and exit
 C: unlock:		3:	3
scripts/rt-tester/t5-l4-pi-boost-deboost.tst +6 -6
Index: linux-2.6.18-rt/scripts/rt-tester/t5-l4-pi-boost-deboost.tst
===================================================================
@@ -108,22 +108,22 @@ T: prioeq:		3:	84
 C: signal:		4: 	0
 W: unlocked:		4: 	3
 T: prioeq:		0: 	83
-T: prioeq:		1:	83
-T: prioeq:		2:	83
-T: prioeq:		3:	83
+T: prioeq:		1:	84
+T: prioeq:		2:	84
+T: prioeq:		3:	84
 
 # Signal T3
 C: signal:		3: 	0
 W: unlocked:		3: 	2
 T: prioeq:		0: 	82
-T: prioeq:		1:	82
-T: prioeq:		2:	82
+T: prioeq:		1:	84
+T: prioeq:		2:	84
 
 # Signal T2
 C: signal:		2: 	0
 W: unlocked:		2: 	1
 T: prioeq:		0: 	81
-T: prioeq:		1:	81
+T: prioeq:		1:	84
 
 # Signal T1
 C: signal:		1: 	0

--

#9 lore raw

PATCH 4/5 Fix timeout bug in rtmutex in 2.6.18-rt

In reply to a message not in the archive
 Documentation/rt-mutex-design.txt |   45 +++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)
Documentation/rt-mutex-design.txt +41 -5
Index: linux-2.6.18-rt/Documentation/rt-mutex-design.txt
===================================================================
@@ -229,6 +229,23 @@ pi_list.  This list is protected by a sp
 called pi_lock.  This lock may also be taken in interrupt context, so when
 locking the pi_lock, interrupts must be disabled.
 
+Boosting prio sched lifo
+------------------------
+A task's boosting prio is used to avoid lowering a task priority below what
+the priority it is boosting another to. A task is never given a priority
+less than boosting prio. This is needed because in the event of a signal or a
+timeout the task has to perform the deboosting of the owner. But if it
+already has lower priority it might not get the needed CPU to do that.
+boosting prio is reset when the task gets the lock or it is signalled/timed out
+and have done it's deboosting. For that reason the extra boosting is only
+giving to tasks running inside the down operations. But while inside a down
+operation boosting prio is never lowered. That is the task priority is never
+decreased.
+While boosting prio is active the task is made "sched lifo". I.e. it schedules
+in lifo order among equal priority tasks instead of the usual fifo order. This
+is again done to make sure that a task being signalled while sleeping inside
+the down operation will get the CPU before the task being boosted, such it can
+perform the deboost operation.
 
 Depth of the PI Chain
 ---------------------
@@ -370,11 +387,21 @@ rt_mutex_getprio and rt_mutex_setprio ar
 
 rt_mutex_getprio returns the priority that the task should have.  Either the
 task's own normal priority, or if a process of a higher priority is waiting on
-a mutex owned by the task, then that higher priority should be returned.
+a mutex owned by the task, then that higher priority should be returned. If
+the task is currently boosting another task to some priority, rt_mutex_getprio
+will return at least that priority. This is because deboosting in the event of
+a signal or a timeout must be performed by this task. But if this task has
+lower priority than the task being boosted it might not get a CPU to run on -
+especially on UP machines.
+rt_mutex_getprio_real returns the task's priority without taking boosting_prio
+into account. This is used as the priority for the waiter list and thus
+also for the PI list. If rt_mutex_getprio was used the order in the wait_list
+would be incorrect and the task would boost too much.
+
 Since the pi_list of a task holds an order by priority list of all the top
-waiters of all the mutexes that the task owns, rt_mutex_getprio simply needs
-to compare the top pi waiter to its own normal priority, and return the higher
-priority back.
+waiters of all the mutexes that the task owns, rt_mutex_getprio_real simply
+needs to compare the top pi waiter to its own normal priority, and return the
+higher priority back.
 
 (Note:  if looking at the code, you will notice that the lower number of
         prio is returned.  This is because the prio field in the task structure
@@ -680,6 +707,10 @@ If the owner is also blocked on a lock,
 (or deadlock checking is on), we unlock the wait_lock of the mutex and go ahead
 and run rt_mutex_adjust_prio_chain on the owner, as described earlier.
 
+In the second round of the loop we might fail getting the lock but
+waiter.task might not be NULL. In that case we also release the wait_lock and
+call rt_mutex_adjust_prio_chain in case some priority was changed.
+
 Now all locks are released, and if the current process is still blocked on a
 mutex (waiter "task" field is not NULL), then we go to sleep (call schedule).
 
@@ -690,6 +721,7 @@ The schedule can then wake up for a few
   1) we were given pending ownership of the mutex.
   2) we received a signal and was TASK_INTERRUPTIBLE
   3) we had a timeout and was TASK_INTERRUPTIBLE
+  4) our priority was changed and we have to perform priority adjustments
 
 In any of these cases, we continue the loop and once again try to grab the
 ownership of the mutex.  If we succeed, we exit the loop, otherwise we continue
@@ -711,6 +743,8 @@ pi_list of the owner.  If this process w
 the rt_mutex_adjust_prio_chain needs to be executed again on the owner,
 but this time it will be lowering the priorities.
 
+At the end we need to reset boosting prio and adjust our own priority.
+
 
 Unlocking the Mutex
 -------------------
@@ -759,8 +793,10 @@ We now clear the "pi_blocked_on" field o
 the mutex still has waiters pending, we add the new top waiter to the pi_list
 of the pending owner.
 
-Finally we unlock the pi_lock of the pending owner and wake it up.
+We also reset the boosting prio of the pending owner and removes the sched lifo
+property: Now it is the owner and it can't be boosting anyone.
 
+Finally we unlock the pi_lock of the pending owner and wake it up.
 
 Contact
 -------

--

#10 lore raw

PATCH 5/5 Fix timeout bug in rtmutex in 2.6.18-rt

In reply to a message not in the archive
 kernel/futex.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/futex.c +9 -2
Index: linux-2.6.18-rt/kernel/futex.c
===================================================================
@@ -567,6 +567,7 @@ static int wake_futex_pi(u32 __user *uad
 	if (!pi_state)
 		return -EINVAL;
 
+	spin_lock(&pi_state->pi_mutex.wait_lock);
 	new_owner = rt_mutex_next_owner(&pi_state->pi_mutex);
 
 	/*
@@ -589,10 +590,14 @@ static int wake_futex_pi(u32 __user *uad
 		inc_preempt_count();
 		curval = futex_atomic_cmpxchg_inatomic(uaddr, uval, newval);
 		dec_preempt_count();
-		if (curval == -EFAULT)
+		if (curval == -EFAULT) {
+			spin_unlock(&pi_state->pi_mutex.wait_lock);
 			return -EFAULT;
-		if (curval != uval)
+		}
+		if (curval != uval) {
+			spin_unlock(&pi_state->pi_mutex.wait_lock);
 			return -EINVAL;
+		}
 	}
 
 	spin_lock_irq(&pi_state->owner->pi_lock);
@@ -606,6 +611,8 @@ static int wake_futex_pi(u32 __user *uad
 	pi_state->owner = new_owner;
 	spin_unlock_irq(&new_owner->pi_lock);
 
+	spin_unlock(&pi_state->pi_mutex.wait_lock);
+
 	rt_mutex_unlock(&pi_state->pi_mutex);
 
 	return 0;

--