clean up pi_lock in rtmutex
PATCH 1/1 clean up pi_lock in rtmutex
Ingo,
This is pretty much the same patch that I sent to mainline to clean up the rtmutex code. I gave the reasons why in that patch, so I'm not going to repeat them here. This is for 2.6.17-rt7
-- Steve
Signed-off-by Steven Rostedt <[email protected]>
kernel/rtmutex.c +23 -20
@@ -419,7 +419,7 @@ static int task_blocks_on_rt_mutex(struc {struct rt_mutex_waiter *top_waiter = waiter;task_t *owner =rt_mutex_owner (lock); -int boost =0 , res; +int chain_walk =0 , res;unsigned long flags;spin_lock_irqsave (¤t->pi_lock, flags);
@@ -444,23 +444,24 @@ static int task_blocks_on_rt_mutex(strucplist_add (&waiter->pi_list_entry, &owner->pi_waiters);__rt_mutex_adjust_prio (owner); -if (owner->pi_blocked_on) { - boost =1 ; -get_task_struct (owner); - } -spin_unlock_irqrestore (&owner->pi_lock, flags); - } -else if (debug_rt_mutex_detect_deadlock (waiter, detect_deadlock)) { -spin_lock_irqsave (&owner->pi_lock, flags); -if (owner->pi_blocked_on) { - boost =1 ; -get_task_struct (owner); - } +if (owner->pi_blocked_on) + chain_walk =1 ; +spin_unlock_irqrestore (&owner->pi_lock, flags); } -if (!boost) +else if (debug_rt_mutex_detect_deadlock (waiter, detect_deadlock)) + chain_walk =1 ; + +if (!chain_walk)return 0 ; +/* +* The owner can't disappear while holding a lock, +* so the owner struct is protected by wait_lock. +* Gets dropped in rt_mutex_adjust_prio_chain()! +*/ +get_task_struct (owner); +spin_unlock (&lock->wait_lock); res = rt_mutex_adjust_prio_chain(owner, detect_deadlock, lock,
@@ -542,7 +543,7 @@ static void remove_waiter(struct rt_mute struct rt_mutex_waiter *waiter __IP_DECL__) {int first = (waiter ==rt_mutex_top_waiter (lock)); -int boost =0 ; +int chain_walk =0 ;task_t *owner =rt_mutex_owner (lock);unsigned long flags;
@@ -566,18 +567,20 @@ static void remove_waiter(struct rt_mute }__rt_mutex_adjust_prio (owner); -if (owner->pi_blocked_on) { - boost =1 ; -get_task_struct (owner); - } +if (owner->pi_blocked_on) + chain_walk =1 ; +spin_unlock_irqrestore (&owner->pi_lock, flags); }WARN_ON (!plist_node_empty (&waiter->pi_list_entry)); -if (!boost) +if (!chain_walk)return ; +/* gets dropped in rt_mutex_adjust_prio_chain()! */ +get_task_struct (owner); +spin_unlock (&lock->wait_lock); rt_mutex_adjust_prio_chain(owner, 0, lock, NULL __IP__);