- When executing the 'tryself' branch in sched_pickcpu() look at the

lowest priority on the queue for the current cpu vs curthread's
   priority.  In the case that curthread is waking up many threads of a
   lower priority as would happen with a turnstile_broadcast() or wakeup()
   of many threads this prevents them from all ending up on the current cpu.
 - In sched_add() make the relationship between a scheduled ithread and
   the current cpu advisory rather than strict.  Only give the ithread
   affinity for the current cpu if it's actually being scheduled from
   a hardware interrupt.  This prevents it from migrating when it simply
   blocks on a lock.

Sponsored by:	Nokia
This commit is contained in:
Jeff Roberson 2008-01-15 09:03:09 +00:00
parent 139edb19d9
commit a755f21484

View File

@ -1113,7 +1113,7 @@ sched_pickcpu(struct td_sched *ts, int flags)
* This may improve locality among sleepers and wakers when there
* is shared data.
*/
if (tryself && pri < curthread->td_priority) {
if (tryself && pri < TDQ_CPU(self)->tdq_lowpri) {
CTR1(KTR_ULE, "tryself %d",
curthread->td_priority);
return (self);
@ -2410,9 +2410,10 @@ sched_add(struct thread *td, int flags)
* Pick the destination cpu and if it isn't ours transfer to the
* target cpu.
*/
if (td->td_priority <= PRI_MAX_ITHD && THREAD_CAN_MIGRATE(td))
cpu = cpuid;
else if (!THREAD_CAN_MIGRATE(td))
if (td->td_priority <= PRI_MAX_ITHD && THREAD_CAN_MIGRATE(td) &&
curthread->td_intr_nesting_level)
ts->ts_cpu = cpuid;
if (!THREAD_CAN_MIGRATE(td))
cpu = ts->ts_cpu;
else
cpu = sched_pickcpu(ts, flags);