Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Mar 2012 02:27:04 +0000 (UTC)
From:      Ryan Stone <rstone@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r232757 - stable/8/sys/kern
Message-ID:  <201203100227.q2A2R4GN035390@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rstone
Date: Sat Mar 10 02:27:04 2012
New Revision: 232757
URL: http://svn.freebsd.org/changeset/base/232757

Log:
  MFC r230984:
   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.

Modified:
  stable/8/sys/kern/kern_kthread.c
Directory Properties:
  stable/8/sys/   (props changed)

Modified: stable/8/sys/kern/kern_kthread.c
==============================================================================
--- stable/8/sys/kern/kern_kthread.c	Sat Mar 10 02:26:12 2012	(r232756)
+++ stable/8/sys/kern/kern_kthread.c	Sat Mar 10 02:27:04 2012	(r232757)
@@ -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>
@@ -116,6 +117,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);
@@ -300,6 +304,9 @@ kthread_add(void (*func)(void *), void *
 	PROC_UNLOCK(p);
 
 
+	/* 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?201203100227.q2A2R4GN035390>