aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/locking
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2014-06-07 03:36:13 -0400
committerThomas Gleixner <tglx@linutronix.de>2014-06-21 16:05:30 -0400
commit1ca7b86062ec8473d03c5cdfd336abc8b1c8098c (patch)
tree4d4fb16eebac3bac63a317a406e60f78469c3828 /kernel/locking
parent3eb65aeadf701976b084e9171e16bb7d1e83fbb0 (diff)
rtmutex: Simplify remove_waiter()
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>
Diffstat (limited to 'kernel/locking')
-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 ed88021953df..1e8fdabb19de 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -917,9 +917,9 @@ static void wakeup_next_waiter(struct rt_mutex *lock)
917static void remove_waiter(struct rt_mutex *lock, 917static void remove_waiter(struct rt_mutex *lock,
918 struct rt_mutex_waiter *waiter) 918 struct rt_mutex_waiter *waiter)
919{ 919{
920 int first = (waiter == rt_mutex_top_waiter(lock)); 920 bool is_top_waiter = (waiter == rt_mutex_top_waiter(lock));
921 struct task_struct *owner = rt_mutex_owner(lock); 921 struct task_struct *owner = rt_mutex_owner(lock);
922 struct rt_mutex *next_lock = NULL; 922 struct rt_mutex *next_lock;
923 unsigned long flags; 923 unsigned long flags;
924 924
925 raw_spin_lock_irqsave(&current->pi_lock, flags); 925 raw_spin_lock_irqsave(&current->pi_lock, flags);
@@ -927,29 +927,31 @@ static void remove_waiter(struct rt_mutex *lock,
927 current->pi_blocked_on = NULL; 927 current->pi_blocked_on = NULL;
928 raw_spin_unlock_irqrestore(&current->pi_lock, flags); 928 raw_spin_unlock_irqrestore(&current->pi_lock, flags);
929 929
930 if (!owner) 930 /*
931 * Only update priority if the waiter was the highest priority
932 * waiter of the lock and there is an owner to update.
933 */
934 if (!owner || !is_top_waiter)
931 return; 935 return;
932 936
933 if (first) { 937 raw_spin_lock_irqsave(&owner->pi_lock, flags);
934
935 raw_spin_lock_irqsave(&owner->pi_lock, flags);
936 938
937 rt_mutex_dequeue_pi(owner, waiter); 939 rt_mutex_dequeue_pi(owner, waiter);
938 940
939 if (rt_mutex_has_waiters(lock)) { 941 if (rt_mutex_has_waiters(lock))
940 struct rt_mutex_waiter *next; 942 rt_mutex_enqueue_pi(owner, rt_mutex_top_waiter(lock));
941 943
942 next = rt_mutex_top_waiter(lock); 944 __rt_mutex_adjust_prio(owner);
943 rt_mutex_enqueue_pi(owner, next);
944 }
945 __rt_mutex_adjust_prio(owner);
946 945
947 /* Store the lock on which owner is blocked or NULL */ 946 /* Store the lock on which owner is blocked or NULL */
948 next_lock = task_blocked_on_lock(owner); 947 next_lock = task_blocked_on_lock(owner);
949 948
950 raw_spin_unlock_irqrestore(&owner->pi_lock, flags); 949 raw_spin_unlock_irqrestore(&owner->pi_lock, flags);
951 }
952 950
951 /*
952 * Don't walk the chain, if the owner task is not blocked
953 * itself.
954 */
953 if (!next_lock) 955 if (!next_lock)
954 return; 956 return;
955 957