lkml.org 
[lkml]   [2010]   [Dec]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][RT][PATCH 1/4] rtmutex: Only save lock depth once in spin_slowlock
From: Steven Rostedt <srostedt@redhat.com>

The task that enters the rt_spin_lock_slowlock() will not take or
release the kernel lock again until it leaves the fuction.
There's no reason that we need to save and restore the lock depth
for each iteration of the try_lock loop.

Just save and reset the lock depth before entering the loop
and restore it upon exit.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/rtmutex.c | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index 348b1e7..f0ce334 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -821,6 +821,7 @@ rt_spin_lock_slowlock(struct rt_mutex *lock)
struct rt_mutex_waiter waiter;
unsigned long saved_state, flags;
struct task_struct *orig_owner;
+ int saved_lock_depth;

debug_rt_mutex_init_waiter(&waiter);
waiter.task = NULL;
@@ -843,8 +844,14 @@ rt_spin_lock_slowlock(struct rt_mutex *lock)
*/
saved_state = rt_set_current_blocked_state(current->state);

+ /*
+ * Prevent schedule() to drop BKL, while waiting for
+ * the lock ! We restore lock_depth when we come back.
+ */
+ saved_lock_depth = current->lock_depth;
+ current->lock_depth = -1;
+
for (;;) {
- int saved_lock_depth = current->lock_depth;

/* Try to acquire the lock */
if (do_try_to_take_rt_mutex(lock, STEAL_LATERAL))
@@ -863,11 +870,6 @@ rt_spin_lock_slowlock(struct rt_mutex *lock)
continue;
}

- /*
- * Prevent schedule() to drop BKL, while waiting for
- * the lock ! We restore lock_depth when we come back.
- */
- current->lock_depth = -1;
orig_owner = rt_mutex_owner(lock);
get_task_struct(orig_owner);
raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
@@ -883,9 +885,9 @@ rt_spin_lock_slowlock(struct rt_mutex *lock)
put_task_struct(orig_owner);

raw_spin_lock_irqsave(&lock->wait_lock, flags);
- current->lock_depth = saved_lock_depth;
saved_state = rt_set_current_blocked_state(saved_state);
}
+ current->lock_depth = saved_lock_depth;

rt_restore_current_state(saved_state);

--
1.7.2.3



\
 
 \ /
  Last update: 2010-12-23 23:55    [W:0.197 / U:0.612 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site