History

rtmutex: Clean up

Previous patches changed the meaning of the return value of rt_mutex_slowunlock(); update comments and code to reflect this.

Peter Zijlstra committed 9 years ago

Commit aa2bfe51 parent 85e2d4f3 files · +18 −19Browse files

Unified · Split

3 files
  1. kernel/futex.c +4 −3
  2. kernel/locking/rtmutex.c +13 −15
  3. kernel/locking/rtmutex_common.h +1 −1
kernel/futex.c+4−3
@@ -1394,7 +1394,7 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_ · 1393 unmodified lines
13941394 {
13951395 u32 uninitialized_var(curval), newval;
13961396 struct task_struct *new_owner;
1397− bool deboost = false;
1397+ bool postunlock = false;
13981398 DEFINE_WAKE_Q(wake_q);
13991399 int ret = 0;
14001400
@@ -1455,12 +1455,13 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_pi_state *pi_ · 54 unmodified lines
14551455 /*
14561456 * We've updated the uservalue, this unlock cannot fail.
14571457 */
1458− deboost = __rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q);
1458+ postunlock = __rt_mutex_futex_unlock(&pi_state->pi_mutex, &wake_q);
14591459
14601460 out_unlock:
14611461 raw_spin_unlock_irq(&pi_state->pi_mutex.wait_lock);
14621462
1463− rt_mutex_postunlock(&wake_q, deboost);
1463+ if (postunlock)
1464+ rt_mutex_postunlock(&wake_q);
14641465
14651466 return ret;
14661467 }
kernel/locking/rtmutex.c+13−15
@@ -1330,7 +1330,8 @@ static inline int rt_mutex_slowtrylock(struct rt_mutex *lock) · 1329 unmodified lines
13301330
13311331 /*
13321332 * Slow path to release a rt-mutex.
1333− * Return whether the current task needs to undo a potential priority boosting.
1333+ *
1334+ * Return whether the current task needs to call rt_mutex_postunlock().
13341335 */
13351336 static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock,
13361337 struct wake_q_head *wake_q)
@@ -1401,8 +1402,7 @@ static bool __sched rt_mutex_slowunlock(struct rt_mutex *lock, · 64 unmodified lines
14011402
14021403 raw_spin_unlock_irqrestore(&lock->wait_lock, flags);
14031404
1404− /* check PI boosting */
1405− return true;
1405+ return true; /* call rt_mutex_postunlock() */
14061406 }
14071407
14081408 /*
@@ -1449,15 +1449,14 @@ rt_mutex_fasttrylock(struct rt_mutex *lock, · 40 unmodified lines
14491449 }
14501450
14511451 /*
1452− * Undo pi boosting (if necessary) and wake top waiter.
1452+ * Performs the wakeup of the the top-waiter and re-enables preemption.
14531453 */
1454−void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost)
1454+void rt_mutex_postunlock(struct wake_q_head *wake_q)
14551455 {
14561456 wake_up_q(wake_q);
14571457
14581458 /* Pairs with preempt_disable() in rt_mutex_slowunlock() */
1459− if (deboost)
1460− preempt_enable();
1459+ preempt_enable();
14611460 }
14621461
14631462 static inline void
@@ -1466,14 +1465,12 @@ rt_mutex_fastunlock(struct rt_mutex *lock, · 2 unmodified lines
14661465 struct wake_q_head *wqh))
14671466 {
14681467 DEFINE_WAKE_Q(wake_q);
1469− bool deboost;
14701468
14711469 if (likely(rt_mutex_cmpxchg_release(lock, current, NULL)))
14721470 return;
14731471
1474− deboost = slowfn(lock, &wake_q);
1475−
1476− rt_mutex_postunlock(&wake_q, deboost);
1472+ if (slowfn(lock, &wake_q))
1473+ rt_mutex_postunlock(&wake_q);
14771474 }
14781475
14791476 /**
@@ -1593,19 +1590,20 @@ bool __sched __rt_mutex_futex_unlock(struct rt_mutex *lock, · 113 unmodified lines
15931590 */
15941591 preempt_disable();
15951592
1596− return true; /* deboost and wakeups */
1593+ return true; /* call postunlock() */
15971594 }
15981595
15991596 void __sched rt_mutex_futex_unlock(struct rt_mutex *lock)
16001597 {
16011598 DEFINE_WAKE_Q(wake_q);
1602− bool deboost;
1599+ bool postunlock;
16031600
16041601 raw_spin_lock_irq(&lock->wait_lock);
1605− deboost = __rt_mutex_futex_unlock(lock, &wake_q);
1602+ postunlock = __rt_mutex_futex_unlock(lock, &wake_q);
16061603 raw_spin_unlock_irq(&lock->wait_lock);
16071604
1608− rt_mutex_postunlock(&wake_q, deboost);
1605+ if (postunlock)
1606+ rt_mutex_postunlock(&wake_q);
16091607 }
16101608
16111609 /**
kernel/locking/rtmutex_common.h+1−1
@@ -122,7 +122,7 @@ extern void rt_mutex_futex_unlock(struct rt_mutex *lock); · 121 unmodified lines
122122 extern bool __rt_mutex_futex_unlock(struct rt_mutex *lock,
123123 struct wake_q_head *wqh);
124124
125−extern void rt_mutex_postunlock(struct wake_q_head *wake_q, bool deboost);
125+extern void rt_mutex_postunlock(struct wake_q_head *wake_q);
126126
127127 #ifdef CONFIG_DEBUG_RT_MUTEXES
128128 # include "rtmutex-debug.h"