Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Feb 2012 16:49:30 +0000 (UTC)
From:      Ryan Stone <rstone@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r230984 - head/sys/kern
Message-ID:  <201202041649.q14GnUnI043572@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/param.h>
 #include <sys/systm.h>
+#include <sys/cpuset.h>
 #include <sys/kthread.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202041649.q14GnUnI043572>