From a755f21484f91b2d6157e6ca2e201e7d11093484 Mon Sep 17 00:00:00 2001 From: Jeff Roberson Date: Tue, 15 Jan 2008 09:03:09 +0000 Subject: [PATCH] - 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 --- sys/kern/sched_ule.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c index 074e85b0e86..9957a25c32f 100644 --- a/sys/kern/sched_ule.c +++ b/sys/kern/sched_ule.c @@ -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);