mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH -rt] clean up pi_lock in rtmutex
@ 2006-08-01 13:56 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2006-08-01 13:56 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Thomas Gleixner, LKML, Oleg Nesterov, Esben Nielsen

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 <rostedt@goodmis.org>

Index: linux-2.6.17-rt7/kernel/rtmutex.c
===================================================================
--- linux-2.6.17-rt7.orig/kernel/rtmutex.c	2006-08-01 09:40:36.000000000 -0400
+++ linux-2.6.17-rt7/kernel/rtmutex.c	2006-08-01 09:53:41.000000000 -0400
@@ -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(&current->pi_lock, flags);
@@ -444,23 +444,24 @@ static int task_blocks_on_rt_mutex(struc
 		plist_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__);



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-08-01 13:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-01 13:56 [PATCH -rt] clean up pi_lock in rtmutex Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome