From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [RFC][RT][PATCH 1/4] rtmutex: Only save lock depth once in spin_slowlock
Date: Thu, 23 Dec 2010 17:47:56 -0500 [thread overview]
Message-ID: <20101223225115.676407152@goodmis.org> (raw)
In-Reply-To: 20101223224755.078983538@goodmis.org
[-- Attachment #1: 0001-rtmutex-Only-save-lock-depth-once-in-spin_slowlock.patch --]
[-- Type: text/plain, Size: 2101 bytes --]
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
next prev parent reply other threads:[~2010-12-23 22:51 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-23 22:47 [RFC][RT][PATCH 0/4] rtmutex: Simplify PI code Steven Rostedt
2010-12-23 22:47 ` Steven Rostedt [this message]
2010-12-23 22:47 ` [RFC][RT][PATCH 2/4] rtmutex: Try to take lock early in rt_spin_lock_slowlock() Steven Rostedt
2010-12-23 22:47 ` [RFC][RT][PATCH 3/4] rtmutex: Revert Optimize rt lock wakeup Steven Rostedt
2010-12-24 4:45 ` Gregory Haskins
2010-12-24 4:54 ` Steven Rostedt
2010-12-28 14:06 ` Gregory Haskins
2011-01-03 19:06 ` Steven Rostedt
2011-01-03 20:22 ` Steven Rostedt
2011-01-04 15:19 ` Peter W. Morreale
2011-01-04 15:47 ` Steven Rostedt
2011-01-04 17:15 ` Peter W. Morreale
2011-01-04 17:27 ` Steven Rostedt
2011-01-04 17:45 ` Peter W. Morreale
2011-01-04 18:06 ` Steven Rostedt
2011-01-04 20:48 ` Peter W. Morreale
2011-01-04 17:24 ` Peter W. Morreale
2011-01-10 14:49 ` Gregory Haskins
[not found] ` <4D13DF250200005A000793E1@novell.com>
2010-12-24 15:47 ` Peter W. Morreale
2010-12-23 22:47 ` [RFC][RT][PATCH 4/4] rtmutex: Ensure only the top waiter or higher priority task can take the lock Steven Rostedt
2011-01-04 4:02 ` Steven Rostedt
2011-01-05 7:12 ` Lai Jiangshan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101223225115.676407152@goodmis.org \
--to=rostedt@goodmis.org \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox