From owner-svn-src-head@FreeBSD.ORG Sat Mar 14 11:41:36 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A4EA0106566B; Sat, 14 Mar 2009 11:41:36 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 937908FC1A; Sat, 14 Mar 2009 11:41:36 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EBfaoL092221; Sat, 14 Mar 2009 11:41:36 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EBfaZX092220; Sat, 14 Mar 2009 11:41:36 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <200903141141.n2EBfaZX092220@svn.freebsd.org> From: Jeff Roberson Date: Sat, 14 Mar 2009 11:41:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189787 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 11:41:37 -0000 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 - 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 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;