[PATCH 4/4] rt_mutex: possible bugfixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is my first look at the kernel/rt.c, so I am probably very wrong.


pi_setprio()
	if (rt_task(p) && plist_empty(&w->pi_list)) {
	                  ^^^^^^^^^^^
		plist_init(&w->pi_list, prio);
		plist_add(&w->pi_list, &lock->owner->pi_waiters);

plist_empty() checks list_empty(&w->pi_list->dp_node), this does not
garantees that this w->pi_list is not on list, because all nodes with
the same priority have empty ->dp_node, except the first one.
I have changed this to plist_unhashed(&w->pi_list).


__up_mutex()
	RACE_BUG_ON(!lock->wait_list.dp_node.prev && !lock->wait_list.dp_node.next);
	                                         ^^^^
I guess, this should be '||' ?


init_lists()
	// we have to do this until the static initializers get fixed:
	if (!lock->wait_list.dp_node.prev && !lock->wait_list.dp_node.next)

I can't understand this comment, just changed ->dp_node to ->prio_list.

Signed-off-by: Oleg Nesterov <[email protected]>

--- V0.7.47-01/kernel/rt.c~3_UNSURE	2005-05-09 19:13:33.000000000 +0400
+++ V0.7.47-01/kernel/rt.c	2005-05-09 19:43:47.000000000 +0400
@@ -627,7 +627,7 @@ static void pi_setprio(struct rt_mutex *
 		lock = w->lock;
 		TRACE_BUG_ON(!lock);
 		TRACE_BUG_ON(!lock->owner);
-		if (rt_task(p) && plist_empty(&w->pi_list)) {
+		if (rt_task(p) && plist_unhashed(&w->pi_list)) {
 			TRACE_BUG_ON(was_rt);
 			w->pi_list.prio = prio;
 			plist_add(&w->pi_list, &lock->owner->pi_waiters);
@@ -645,7 +645,7 @@ static void pi_setprio(struct rt_mutex *
 		 * (TODO: this can be unfair to SCHED_NORMAL tasks if they
 		 *        get PI handled.)
 		 */
-		if (!rt_task(p) && !plist_empty(&w->pi_list)) {
+		if (!rt_task(p) && !plist_unhashed(&w->pi_list)) {
 			TRACE_BUG_ON(!was_rt);
 			plist_del(&w->pi_list);
 			plist_del(&w->list);
@@ -788,7 +788,7 @@ static inline struct task_struct * pick_
 static inline void init_lists(struct rt_mutex *lock)
 {
 	// we have to do this until the static initializers get fixed:
-	if (!lock->wait_list.dp_node.prev && !lock->wait_list.dp_node.next)
+	if (!lock->wait_list.prio_list.prev && !lock->wait_list.prio_list.next)
 		pl_head_init(&lock->wait_list);
 #ifdef CONFIG_RT_DEADLOCK_DETECT
 	if (!lock->held_list.prev && !lock->held_list.next)
@@ -1315,7 +1315,7 @@ static void __up_mutex(struct rt_mutex *
 	trace_lock_irqsave(&trace_lock, flags);
 	TRACE_BUG_ON(!irqs_disabled());
 	spin_lock(&lock->wait_lock);
-	TRACE_BUG_ON(!lock->wait_list.dp_node.prev && !lock->wait_list.dp_node.next);
+	TRACE_BUG_ON(!lock->wait_list.prio_list.prev || !lock->wait_list.prio_list.next);
 
 #ifdef CONFIG_RT_DEADLOCK_DETECT
 	TRACE_WARN_ON(list_empty(&lock->held_list));
-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux