Make use of wake-queues and enable the wakeup to occur after releasing the wait_lock. This is similar to what we do with rtmutex top waiter, slightly shortening the critical region and allow other waiters to acquire the wait_lock sooner. In low contention cases it can also help the recently woken waiter to find the wait_lock available (fastpath) when it continues execution.
Showing the changes to kernel/locking (1 of 1 file). Show all
Unified · Split
| @@ -716,6 +716,7 @@ static inline void · 715 unmodified lines | ||
| 716 | 716 | __mutex_unlock_common_slowpath(struct mutex *lock, int nested) |
| 717 | 717 | { |
| 718 | 718 | unsigned long flags; |
| 719 | + WAKE_Q(wake_q); | |
| 719 | 720 | |
| 720 | 721 | /* |
| 721 | 722 | * As a performance measurement, release the lock before doing other |
| @@ -743,11 +744,11 @@ __mutex_unlock_common_slowpath(struct mutex *lock, int nested) · 21 unmodified lines | ||
| 743 | 744 | struct mutex_waiter, list); |
| 744 | 745 | |
| 745 | 746 | debug_mutex_wake_waiter(lock, waiter); |
| 746 | − | |
| 747 | − wake_up_process(waiter->task); | |
| 747 | + wake_q_add(&wake_q, waiter->task); | |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | spin_unlock_mutex(&lock->wait_lock, flags); |
| 751 | + wake_up_q(&wake_q); | |
| 751 | 752 | } |
| 752 | 753 | |
| 753 | 754 | /* |