Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Peter Zijlstra and committed by
Ingo Molnar
34c6bc2c fb0527bd

+7
+7
kernel/locking/mutex.c
··· 468 468 } 469 469 osq_unlock(&lock->osq); 470 470 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(); 471 478 #endif 472 479 spin_lock_mutex(&lock->wait_lock, flags); 473 480