aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-06-07 09:36:13 +0200
committerAnders Roxell <anders.roxell@linaro.org>2015-06-01 12:03:32 +0200
commit801d5f919e8e7f455996444a892219883ec8bc99 (patch)
treeeb11e52b30c6eb46a5b1ca3706a7f027a82e1d9c
parented77fcdc44d7384a2339c61414a83538368f7771 (diff)
downloadlinux-linaro-stable-801d5f919e8e7f455996444a892219883ec8bc99.tar.gz
rtmutex: Simplify remove_waiter()
upstream commit: 1ca7b86062ec8473d03c5cdfd336abc8b1c8098c Exit right away, when the removed waiter was not the top priority waiter on the lock. Get rid of the extra indent level. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Steven Rostedt <rostedt@goodmis.org> Reviewed-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Conflicts: kernel/locking/rtmutex.c
-rw-r--r--kernel/locking/rtmutex.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 400026ec7f05..6c74a0525dcb 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -985,7 +985,7 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
static void remove_waiter(struct rt_mutex *lock,
struct rt_mutex_waiter *waiter)
{
- int first = (waiter == rt_mutex_top_waiter(lock));
+ bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock));
struct task_struct *owner = rt_mutex_owner(lock);
struct rt_mutex *next_lock = NULL;
unsigned long flags;
@@ -995,30 +995,32 @@ static void remove_waiter(struct rt_mutex *lock,
current->pi_blocked_on = NULL;
raw_spin_unlock_irqrestore(&current->pi_lock, flags);
- if (!owner)
+ /*
+ * Only update priority if the waiter was the highest priority
+ * waiter of the lock and there is an owner to update.
+ */
+ if (!owner || !is_top_waiter)
return;
- if (first) {
+ raw_spin_lock_irqsave(&owner->pi_lock, flags);
- raw_spin_lock_irqsave(&owner->pi_lock, flags);
+ rt_mutex_dequeue_pi(owner, waiter);
- rt_mutex_dequeue_pi(owner, waiter);
+ if (rt_mutex_has_waiters(lock))
+ rt_mutex_enqueue_pi(owner, rt_mutex_top_waiter(lock));
- if (rt_mutex_has_waiters(lock)) {
- struct rt_mutex_waiter *next;
+ __rt_mutex_adjust_prio(owner);
- next = rt_mutex_top_waiter(lock);
- rt_mutex_enqueue_pi(owner, next);
- }
- __rt_mutex_adjust_prio(owner);
-
- /* Store the lock on which owner is blocked or NULL */
- if (rt_mutex_real_waiter(owner->pi_blocked_on))
- next_lock = task_blocked_on_lock(owner);
+ /* Store the lock on which owner is blocked or NULL */
+ if (rt_mutex_real_waiter(owner->pi_blocked_on))
+ next_lock = task_blocked_on_lock(owner);
- raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
- }
+ raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
+ /*
+ * Don't walk the chain, if the owner task is not blocked
+ * itself.
+ */
if (!next_lock)
return;