Date: Sat, 14 Mar 2009 11:41:36 +0000 (UTC) From: Jeff Roberson <jeff@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r189787 - head/sys/kern Message-ID: <200903141141.n2EBfaZX092220@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jeff Date: Sat Mar 14 11:41:36 2009 New Revision: 189787 URL: http://svn.freebsd.org/changeset/base/189787 Log: - Fix an error that occurs when mp_ncpu is an odd number. steal_thresh is calculated as 0 which causes errors elsewhere. Submitted by: KOIE Hidetaka <koie@suri.co.jp> - When sched_affinity() is called with a thread that is not curthread we need to handle the ON_RUNQ() case by adding the thread to the correct run queue. Submitted by: Justin Teller <justin.teller@gmail.com> MFC after: 1 Week Modified: head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_ule.c ============================================================================== --- head/sys/kern/sched_ule.c Sat Mar 14 08:34:45 2009 (r189786) +++ head/sys/kern/sched_ule.c Sat Mar 14 11:41:36 2009 (r189787) @@ -1337,11 +1337,11 @@ sched_initticks(void *dummy) */ balance_interval = realstathz; /* - * Set steal thresh to log2(mp_ncpu) but no greater than 4. This - * prevents excess thrashing on large machines and excess idle on - * smaller machines. + * Set steal thresh to roughly log2(mp_ncpu) but no greater than 4. + * This prevents excess thrashing on large machines and excess idle + * on smaller machines. */ - steal_thresh = min(ffs(mp_ncpus) - 1, 3); + steal_thresh = min(fls(mp_ncpus) - 1, 3); affinity = SCHED_AFFINITY_DEFAULT; #endif } @@ -2417,6 +2417,11 @@ sched_affinity(struct thread *td) ts = td->td_sched; if (THREAD_CAN_SCHED(td, ts->ts_cpu)) return; + if (TD_ON_RUNQ(td)) { + sched_rem(td); + sched_add(td, SRQ_BORING); + return; + } if (!TD_IS_RUNNING(td)) return; td->td_flags |= TDF_NEEDRESCHED;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200903141141.n2EBfaZX092220>