Skip to content

Commit 34c6bc2

Browse files
Peter Zijlstraingomolnar
authored andcommitted
locking/mutexes: Add extra reschedule point
Add in an extra reschedule in an attempt to avoid getting reschedule the moment we've acquired the lock. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/tip-zah5eyn9gu7qlgwh9r6n2anc@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent fb0527b commit 34c6bc2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎kernel/locking/mutex.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
468468
}
469469
osq_unlock(&lock->osq);
470470
slowpath:
471+
/*
472+
* If we fell out of the spin path because of need_resched(),
473+
* reschedule now, before we try-lock the mutex. This avoids getting
474+
* scheduled out right after we obtained the mutex.
475+
*/
476+
if (need_resched())
477+
schedule_preempt_disabled();
471478
#endif
472479
spin_lock_mutex(&lock->wait_lock, flags);
473480

0 commit comments

Comments
 (0)