From owner-svn-src-head@FreeBSD.ORG Sat Feb 4 16:49:30 2012 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 5AE2310656E8; Sat, 4 Feb 2012 16:49:30 +0000 (UTC) (envelope-from rstone@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 44F268FC13; Sat, 4 Feb 2012 16:49:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q14GnU7d043574; Sat, 4 Feb 2012 16:49:30 GMT (envelope-from rstone@svn.freebsd.org) Received: (from rstone@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q14GnUnI043572; Sat, 4 Feb 2012 16:49:30 GMT (envelope-from rstone@svn.freebsd.org) Message-Id: <201202041649.q14GnUnI043572@svn.freebsd.org> From: Ryan Stone Date: Sat, 4 Feb 2012 16:49:30 +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: r230984 - 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, 04 Feb 2012 16:49:30 -0000 Author: rstone Date: Sat Feb 4 16:49:29 2012 New Revision: 230984 URL: http://svn.freebsd.org/changeset/base/230984 Log: Whenever a new kernel thread is spawned, explicitly clear any CPU affinity set on the new thread. This prevents the thread from inadvertently inheriting affinity from a random sibling. Submitted by: attilio Tested by: pho MFC after: 1 week Modified: head/sys/kern/kern_kthread.c Modified: head/sys/kern/kern_kthread.c ============================================================================== --- head/sys/kern/kern_kthread.c Sat Feb 4 15:43:16 2012 (r230983) +++ head/sys/kern/kern_kthread.c Sat Feb 4 16:49:29 2012 (r230984) @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -117,6 +118,9 @@ kproc_create(void (*func)(void *), void /* call the processes' main()... */ cpu_set_fork_handler(td, func, arg); + + /* Avoid inheriting affinity from a random parent. */ + cpuset_setthread(td->td_tid, cpuset_root); thread_lock(td); TD_SET_CAN_RUN(td); sched_prio(td, PVM); @@ -299,6 +303,9 @@ kthread_add(void (*func)(void *), void * tidhash_add(newtd); + /* Avoid inheriting affinity from a random parent. */ + cpuset_setthread(newtd->td_tid, cpuset_root); + /* Delay putting it on the run queue until now. */ if (!(flags & RFSTOPPED)) { thread_lock(newtd);