Skip to contentSkip to conversation

Avoid deadlock in rt_mutex_start_proxy_lock()

tip/urgent Darren Hart 1 participant 2 messages Aug 5, 2009 – Aug 6, 2009

lore
Share & tools
lore
#0 lore raw

From: Darren Hart <[email protected]>

In the event of a lock steal or owner died, rt_mutex_start_proxy_lock() will give the rt_mutex to the waiting task, but it fails to release the wait_lock. This leads to subsequent deadlocks when other tasks try to acquire the rt_mutex.

I also removed a few extra blank lines that really spaced this routine out. I must have been high on the \n when I wrote this originally...

Note: This is the mainline version, a separate patch was sent for [RT]

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Ingo Molnar <[email protected]>
CC Dinakar Guniguntala <[email protected]>
CC John Stultz <[email protected]>

---

kernel/rtmutex.c | 4 +---

1 files changed, 1 insertions(+), 3 deletions(-)
kernel/rtmutex.c +0 -0
index fec77e7..0f2b9bb 100644
@@ -1039,16 +1039,14 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
	if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) {
		/* We got the lock for task. */
		debug_rt_mutex_lock(lock);
-
		rt_mutex_set_owner(lock, task, 0);
-
+		spin_unlock(&lock->wait_lock);
		rt_mutex_deadlock_account_lock(lock, task);
		return 1;
	}

	ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock);

-

	if (ret && !waiter->task) {
		/*
		 * Reset the return value. We might have
Signature · 3 lines
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team
#1 lore raw

[tip:core/urgent] rtmutex: Avoid deadlock in rt_mutex_start_proxy_lock()

Commit-ID:  1bbf20835c4e088667a090ce6523a0f70b62dc76
Gitweb:     http://git.kernel.org/tip/1bbf20835c4e088667a090ce6523a0f70b62dc76
Author:     Darren Hart <[email protected]>
AuthorDate: Wed, 5 Aug 2009 12:05:21 -0700
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 6 Aug 2009 05:50:21 +0200

rtmutex: Avoid deadlock in rt_mutex_start_proxy_lock()

In the event of a lock steal or owner died, rt_mutex_start_proxy_lock() will give the rt_mutex to the waiting task, but it fails to release the wait_lock. This leads to subsequent deadlocks when other tasks try to acquire the rt_mutex.

I also removed a few extra blank lines that really spaced this routine out. I must have been high on the \n when I wrote this originally...

Cc Peter Zijlstra <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Dinakar Guniguntala <[email protected]>
Cc John Stultz <[email protected]>

LKML-Reference: <[email protected]>

---
 kernel/rtmutex.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
kernel/rtmutex.c +1 -3
index fcd107a..29bd4ba 100644
@@ -1039,16 +1039,14 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
 	if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) {
 		/* We got the lock for task. */
 		debug_rt_mutex_lock(lock);
-
 		rt_mutex_set_owner(lock, task, 0);
-
+		spin_unlock(&lock->wait_lock);
 		rt_mutex_deadlock_account_lock(lock, task);
 		return 1;
 	}
 
 	ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock);
 
-
 	if (ret && !waiter->task) {
 		/*
 		 * Reset the return value. We might have