Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Jul 2008 18:14:48 GMT
From:      Ed Schouten <ed@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 146141 for review
Message-ID:  <200807281814.m6SIEm9X057487@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=146141

Change 146141 by ed@ed_dull on 2008/07/28 18:14:18

	IFC, before I create another diff.

Affected files ...

.. //depot/projects/mpsafetty/contrib/cvs/doc/HACKING.DOCS#2 integrate
.. //depot/projects/mpsafetty/lib/libc/gen/posix_spawn.3#2 integrate
.. //depot/projects/mpsafetty/lib/libc/gen/posix_spawn_file_actions_addopen.3#2 integrate
.. //depot/projects/mpsafetty/sys/dev/wi/if_wi.c#3 integrate
.. //depot/projects/mpsafetty/sys/dev/wi/if_wivar.h#2 integrate
.. //depot/projects/mpsafetty/sys/kern/sched_4bsd.c#2 integrate
.. //depot/projects/mpsafetty/sys/modules/et/Makefile#2 integrate
.. //depot/projects/mpsafetty/usr.bin/ldd/ldd.c#3 integrate
.. //depot/projects/mpsafetty/usr.sbin/config/config.y#2 integrate
.. //depot/projects/mpsafetty/usr.sbin/config/lang.l#2 integrate

Differences ...

==== //depot/projects/mpsafetty/contrib/cvs/doc/HACKING.DOCS#2 (text+ko) ====

@@ -12,11 +12,7 @@
 @emph{ ... }			emphasis - warnings, stress, etc.  This will be
 				bracketed by underline characters in info files
 				(_ ... _) and in italics in PDF & probably in
-				postscript & HTML.
-@strong{ ... }			Similar to @emph{}, but the effect is to
-				bracket with asterisks in info files (* ... *)
-				and in bold in PDF & probably in postscript &
-				HTML.
+				postscript & HTML.  
 @noindent			Suppresses indentation of the following
 				paragraph.  This can ocassionally be useful
 				after examples and the like.
@@ -26,7 +22,7 @@
 
 Preformatted text should be marked as such (use @example... there may be other
 ways) since many of the final output formats can use relational fonts otherwise
-and marking it as formatted should restrict it to a fixed width font.  Keep
+and marking it as formatted should restrict it to a fixed wiidth font.  Keep
 this sort of text to 80 characters or less per line since larger may not be
 properly viewable for some info users.
 
@@ -37,10 +33,5 @@
 Use lots of index markers.  Scan the index for the current style.  Try to reuse
 an existing entry if the meaning is similar.
 
-`makeinfo' 3.11 or greater is required for output generation since earlier
-versions do not support the @ifnottex & @ifnothtml commands.  There may be
-other commands used in `cvs.texinfo' that are unsupported by earlier versions
-of `makeinfo' by the time you read this.
-
 For more on using texinfo docs, see the `info texinfo' documentation or
 http://www.gnu.org/manual/texinfo/texinfo.html .

==== //depot/projects/mpsafetty/lib/libc/gen/posix_spawn.3#2 (text+ko) ====

@@ -32,7 +32,7 @@
 .\" the referee document.  The original Standard can be obtained online at
 .\"	http://www.opengroup.org/unix/online.html.
 .\"
-.\" $FreeBSD: src/lib/libc/gen/posix_spawn.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $
+.\" $FreeBSD: src/lib/libc/gen/posix_spawn.3,v 1.2 2008/07/28 09:36:56 ed Exp $
 .\"
 .Dd Mar 24, 2008
 .Dt POSIX_SPAWN 3
@@ -452,4 +452,4 @@
 functions first appeared in
 .Fx 8.0 .
 .Sh AUTHORS
-.An Ed Schouten Aq Ed Schouten ed@FreeBSD.org
+.An Ed Schouten Aq ed@FreeBSD.org

==== //depot/projects/mpsafetty/lib/libc/gen/posix_spawn_file_actions_addopen.3#2 (text+ko) ====

@@ -32,7 +32,7 @@
 .\" the referee document.  The original Standard can be obtained online at
 .\"	http://www.opengroup.org/unix/online.html.
 .\"
-.\" $FreeBSD: src/lib/libc/gen/posix_spawn_file_actions_addopen.3,v 1.1 2008/07/28 02:22:19 davidxu Exp $
+.\" $FreeBSD: src/lib/libc/gen/posix_spawn_file_actions_addopen.3,v 1.2 2008/07/28 09:36:56 ed Exp $
 .\"
 .Dd Mar 24, 2008
 .Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3
@@ -179,4 +179,4 @@
 functions first appeared in
 .Fx 8.0 .
 .Sh AUTHORS
-.An Ed Schouten Aq Ed Schouten ed@FreeBSD.org
+.An Ed Schouten Aq ed@FreeBSD.org

==== //depot/projects/mpsafetty/sys/dev/wi/if_wi.c#3 (text+ko) ====

@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi.c,v 1.219 2008/07/26 17:04:30 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/wi/if_wi.c,v 1.220 2008/07/28 17:00:37 imp Exp $");
 
 #define WI_HERMES_STATS_WAR	/* Work around stats counter bug. */
 
@@ -225,6 +225,8 @@
 	{ 0,	NULL,	0 },
 };
 
+static char *wi_firmware_names[] = { "none", "Hermes", "Intersil", "Symbol" };
+
 devclass_t wi_devclass;
 
 int
@@ -237,6 +239,8 @@
 	u_int16_t val;
 	u_int8_t ratebuf[2 + IEEE80211_RATE_SIZE];
 	struct ieee80211_rateset *rs;
+	struct sysctl_ctx_list *sctx;
+	struct sysctl_oid *soid;
 	static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
 		0x00, 0x00, 0x00, 0x00, 0x00, 0x00
 	};
@@ -278,6 +282,25 @@
 		return EOPNOTSUPP; 
 	}
 
+	/* Export info about the device via sysctl */
+	sctx = device_get_sysctl_ctx(dev);
+	soid = device_get_sysctl_tree(dev);
+	SYSCTL_ADD_STRING(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
+	    "firmware_type", CTLFLAG_RD,
+	    wi_firmware_names[sc->sc_firmware_type], 0,
+	    "Firmware type string");
+	SYSCTL_ADD_INT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "sta_version",
+	    CTLFLAG_RD, &sc->sc_sta_firmware_ver, 0,
+	    "Station Firmware version");
+	if (sc->sc_firmware_type == WI_INTERSIL)
+		SYSCTL_ADD_INT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO,
+		    "pri_version", CTLFLAG_RD, &sc->sc_pri_firmware_ver, 0,
+		    "Primary Firmware version");
+	SYSCTL_ADD_XINT(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "nic_id",
+	    CTLFLAG_RD, &sc->sc_nic_id, 0, "NIC id");
+	SYSCTL_ADD_STRING(sctx, SYSCTL_CHILDREN(soid), OID_AUTO, "nic_name",
+	    CTLFLAG_RD, sc->sc_nic_name, 0, "NIC name");
+
 	mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
 	    MTX_DEF | MTX_RECURSE);
 	callout_init_mtx(&sc->sc_watchdog, &sc->sc_mtx, 0);
@@ -1633,25 +1656,26 @@
 	memset(ver, 0, sizeof(ver));
 	len = sizeof(ver);
 	wi_read_rid(sc, WI_RID_CARD_ID, ver, &len);
-	device_printf(sc->sc_dev, "using ");
 
 	sc->sc_firmware_type = WI_NOTYPE;
+	sc->sc_nic_id = le16toh(ver[0]);
 	for (id = wi_card_ident; id->card_name != NULL; id++) {
-		if (le16toh(ver[0]) == id->card_id) {
-			printf("%s", id->card_name);
+		if (sc->sc_nic_id == id->card_id) {
+			sc->sc_nic_name = id->card_name;
 			sc->sc_firmware_type = id->firm_type;
 			break;
 		}
 	}
 	if (sc->sc_firmware_type == WI_NOTYPE) {
-		if (le16toh(ver[0]) & 0x8000) {
-			printf("Unknown PRISM2 chip");
+		if (sc->sc_nic_id & 0x8000) {
 			sc->sc_firmware_type = WI_INTERSIL;
+			sc->sc_nic_name = "Unknown Prism chip";
 		} else {
-			printf("Unknown Lucent chip");
 			sc->sc_firmware_type = WI_LUCENT;
+			sc->sc_nic_name = "Unknown Lucent chip";
 		}
 	}
+	device_printf(sc->sc_dev, "using %s\n", sc->sc_nic_name);
 
 	/* get primary firmware version (Only Prism chips) */
 	if (sc->sc_firmware_type != WI_LUCENT) {
@@ -1684,19 +1708,19 @@
 			    (p[6] - '0') * 10 + (p[7] - '0');
 		}
 	}
-	printf("\n");
-	device_printf(sc->sc_dev, "%s Firmware: ",
-	     sc->sc_firmware_type == WI_LUCENT ? "Lucent" :
-	    (sc->sc_firmware_type == WI_SYMBOL ? "Symbol" : "Intersil"));
-	if (sc->sc_firmware_type != WI_LUCENT)	/* XXX */
-		printf("Primary (%u.%u.%u), ",
-		    sc->sc_pri_firmware_ver / 10000,
-		    (sc->sc_pri_firmware_ver % 10000) / 100,
-		    sc->sc_pri_firmware_ver % 100);
-	printf("Station (%u.%u.%u)\n",
-	    sc->sc_sta_firmware_ver / 10000,
-	    (sc->sc_sta_firmware_ver % 10000) / 100,
-	    sc->sc_sta_firmware_ver % 100);
+	if (bootverbose) {
+		device_printf(sc->sc_dev, "%s Firmware: ",
+		    wi_firmware_names[sc->sc_firmware_type]);
+		if (sc->sc_firmware_type != WI_LUCENT)	/* XXX */
+			printf("Primary (%u.%u.%u), ",
+			    sc->sc_pri_firmware_ver / 10000,
+			    (sc->sc_pri_firmware_ver % 10000) / 100,
+			    sc->sc_pri_firmware_ver % 100);
+		printf("Station (%u.%u.%u)\n",
+		    sc->sc_sta_firmware_ver / 10000,
+		    (sc->sc_sta_firmware_ver % 10000) / 100,
+		    sc->sc_sta_firmware_ver % 100);
+	}
 }
 
 static int

==== //depot/projects/mpsafetty/sys/dev/wi/if_wivar.h#2 (text+ko) ====

@@ -31,7 +31,7 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  * THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/wi/if_wivar.h,v 1.32 2008/04/20 20:35:38 sam Exp $
+ * $FreeBSD: src/sys/dev/wi/if_wivar.h,v 1.33 2008/07/28 17:00:37 imp Exp $
  */
 
 /*
@@ -87,6 +87,8 @@
 #define	WI_SYMBOL	3
 	int			sc_pri_firmware_ver;	/* Primary firmware */
 	int			sc_sta_firmware_ver;	/* Station firmware */
+	unsigned int		sc_nic_id;		/* Type of NIC */
+	char *			sc_nic_name;
 
 	int			wi_bus_type;	/* Bus attachment type */
 	struct resource *	local;

==== //depot/projects/mpsafetty/sys/kern/sched_4bsd.c#2 (text+ko) ====

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/sched_4bsd.c,v 1.126 2008/05/25 01:44:58 jb Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/sched_4bsd.c,v 1.128 2008/07/28 17:25:24 jhb Exp $");
 
 #include "opt_hwpmc_hooks.h"
 #include "opt_sched.h"
@@ -91,6 +91,7 @@
 	fixpt_t		ts_pctcpu;	/* (j) %cpu during p_swtime. */
 	int		ts_cpticks;	/* (j) Ticks of cpu time. */
 	int		ts_slptime;	/* (j) Seconds !RUNNING. */
+	int		ts_flags;
 	struct runq	*ts_runq;	/* runq the thread is currently on */
 };
 
@@ -98,9 +99,15 @@
 #define TDF_DIDRUN	TDF_SCHED0	/* thread actually ran. */
 #define TDF_BOUND	TDF_SCHED1	/* Bound to one CPU. */
 
+/* flags kept in ts_flags */
+#define	TSF_AFFINITY	0x0001		/* Has a non-"full" CPU set. */
+
 #define SKE_RUNQ_PCPU(ts)						\
     ((ts)->ts_runq != 0 && (ts)->ts_runq != &runq)
 
+#define	THREAD_CAN_SCHED(td, cpu)	\
+    CPU_ISSET((cpu), &(td)->td_cpuset->cs_mask)
+
 static struct td_sched td_sched0;
 struct mtx sched_lock;
 
@@ -118,7 +125,9 @@
 static void	resetpriority(struct thread *td);
 static void	resetpriority_thread(struct thread *td);
 #ifdef SMP
-static int	forward_wakeup(int  cpunum);
+static int	sched_pickcpu(struct thread *td);
+static int	forward_wakeup(int cpunum);
+static void	kick_other_cpu(int pri, int cpuid);
 #endif
 
 static struct kproc_desc sched_kp = {
@@ -140,6 +149,7 @@
  * Per-CPU run queues
  */
 static struct runq runq_pcpu[MAXCPU];
+long runq_length[MAXCPU];
 #endif
 
 static void
@@ -269,9 +279,7 @@
 #ifdef PREEMPTION
 	struct thread *ctd;
 	int cpri, pri;
-#endif
 
-#ifdef PREEMPTION
 	/*
 	 * The new thread should not preempt the current thread if any of the
 	 * following conditions are true:
@@ -442,7 +450,7 @@
 	sx_slock(&allproc_lock);
 	FOREACH_PROC_IN_SYSTEM(p) {
 		PROC_LOCK(p);
-		FOREACH_THREAD_IN_PROC(p, td) { 
+		FOREACH_THREAD_IN_PROC(p, td) {
 			awake = 0;
 			thread_lock(td);
 			ts = td->td_sched;
@@ -489,11 +497,10 @@
 #endif
 				ts->ts_cpticks = 0;
 			}
-			/* 
+			/*
 			 * If there are ANY running threads in this process,
 			 * then don't count it as sleeping.
-XXX  this is broken
-
+			 * XXX: this is broken.
 			 */
 			if (awake) {
 				if (ts->ts_slptime > 1) {
@@ -519,9 +526,9 @@
 		      	resetpriority(td);
 			resetpriority_thread(td);
 			thread_unlock(td);
-		} /* end of thread loop */
+		}
 		PROC_UNLOCK(p);
-	} /* end of process loop */
+	}
 	sx_sunlock(&allproc_lock);
 }
 
@@ -616,6 +623,7 @@
 }
 
 /* External interfaces start here */
+
 /*
  * Very early in the boot some setup of scheduler-specific
  * parts of proc0 and of some scheduler resources needs to be done.
@@ -644,7 +652,7 @@
 #endif
 }
 
-int 
+int
 sched_rr_interval(void)
 {
 	if (sched_quantum == 0)
@@ -691,7 +699,7 @@
 }
 
 /*
- * charge childs scheduling cpu usage to parent.
+ * Charge child's scheduling CPU usage to parent.
  */
 void
 sched_exit(struct proc *p, struct thread *td)
@@ -734,6 +742,7 @@
 	childtd->td_cpuset = cpuset_ref(td->td_cpuset);
 	ts = childtd->td_sched;
 	bzero(ts, sizeof(*ts));
+	ts->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY);
 }
 
 void
@@ -765,7 +774,7 @@
 sched_priority(struct thread *td, u_char prio)
 {
 	CTR6(KTR_SCHED, "sched_prio: %p(%s) prio %d newprio %d by %p(%s)",
-	    td, td->td_name, td->td_priority, prio, curthread, 
+	    td, td->td_name, td->td_priority, prio, curthread,
 	    curthread->td_name);
 
 	THREAD_LOCK_ASSERT(td, MA_OWNED);
@@ -904,7 +913,8 @@
 	p = td->td_proc;
 
 	THREAD_LOCK_ASSERT(td, MA_OWNED);
-	/*  
+
+	/* 
 	 * Switch to the sched lock to fix things up and pick
 	 * a new thread.
 	 */
@@ -916,13 +926,14 @@
 	if ((p->p_flag & P_NOLOAD) == 0)
 		sched_load_rem();
 
-	if (newtd) 
+	if (newtd)
 		newtd->td_flags |= (td->td_flags & TDF_NEEDRESCHED);
 
 	td->td_lastcpu = td->td_oncpu;
 	td->td_flags &= ~TDF_NEEDRESCHED;
 	td->td_owepreempt = 0;
 	td->td_oncpu = NOCPU;
+
 	/*
 	 * At the last moment, if this thread is still marked RUNNING,
 	 * then put it back on the run queue as it has not been suspended
@@ -943,12 +954,12 @@
 		}
 	}
 	if (newtd) {
-		/* 
+		/*
 		 * The thread we are about to run needs to be counted
 		 * as if it had been added to the run queue and selected.
 		 * It came from:
 		 * * A preemption
-		 * * An upcall 
+		 * * An upcall
 		 * * A followon
 		 */
 		KASSERT((newtd->td_inhibitors == 0),
@@ -985,13 +996,14 @@
 		/*
 		 * Where am I?  What year is it?
 		 * We are in the same thread that went to sleep above,
-		 * but any amount of time may have passed. All out context
+		 * but any amount of time may have passed. All our context
 		 * will still be available as will local variables.
 		 * PCPU values however may have changed as we may have
 		 * changed CPU so don't trust cached values of them.
 		 * New threads will go to fork_exit() instead of here
 		 * so if you change things here you may need to change
 		 * things there too.
+		 *
 		 * If the thread above was exiting it will never wake
 		 * up again here, so either it has saved everything it
 		 * needed to, or the thread_wait() or wait() will
@@ -1030,14 +1042,11 @@
 }
 
 #ifdef SMP
-/* enable HTT_2 if you have a 2-way HTT cpu.*/
 static int
-forward_wakeup(int  cpunum)
+forward_wakeup(int cpunum)
 {
-	cpumask_t map, me, dontuse;
-	cpumask_t map2;
 	struct pcpu *pc;
-	cpumask_t id, map3;
+	cpumask_t dontuse, id, map, map2, map3, me;
 
 	mtx_assert(&sched_lock, MA_OWNED);
 
@@ -1051,14 +1060,13 @@
 
 	forward_wakeups_requested++;
 
-/*
- * check the idle mask we received against what we calculated before
- * in the old version.
- */
+	/*
+	 * Check the idle mask we received against what we calculated
+	 * before in the old version.
+	 */
 	me = PCPU_GET(cpumask);
-	/* 
-	 * don't bother if we should be doing it ourself..
-	 */
+
+	/* Don't bother if we should be doing it ourself. */
 	if ((me & idle_cpus_mask) && (cpunum == NOCPU || me == (1 << cpunum)))
 		return (0);
 
@@ -1067,7 +1075,7 @@
 	if (forward_wakeup_use_loop) {
 		SLIST_FOREACH(pc, &cpuhead, pc_allcpu) {
 			id = pc->pc_cpumask;
-			if ( (id & dontuse) == 0 &&
+			if ((id & dontuse) == 0 &&
 			    pc->pc_curthread == pc->pc_idlethread) {
 				map3 |= id;
 			}
@@ -1078,18 +1086,19 @@
 		map = 0;
 		map = idle_cpus_mask & ~dontuse;
 
-		/* If they are both on, compare and use loop if different */
+		/* If they are both on, compare and use loop if different. */
 		if (forward_wakeup_use_loop) {
 			if (map != map3) {
-				printf("map (%02X) != map3 (%02X)\n",
-						map, map3);
+				printf("map (%02X) != map3 (%02X)\n", map,
+				    map3);
 				map = map3;
 			}
 		}
 	} else {
 		map = map3;
 	}
-	/* If we only allow a specific CPU, then mask off all the others */
+
+	/* If we only allow a specific CPU, then mask off all the others. */
 	if (cpunum != NOCPU) {
 		KASSERT((cpunum <= mp_maxcpus),("forward_wakeup: bad cpunum."));
 		map &= (1 << cpunum);
@@ -1102,7 +1111,7 @@
 			}
 		}
 
-		/* set only one bit */ 
+		/* Set only one bit. */
 		if (forward_wakeup_use_single) {
 			map = map & ((~map) + 1);
 		}
@@ -1116,23 +1125,21 @@
 		printf("forward_wakeup: Idle processor not found\n");
 	return (0);
 }
-#endif
 
-#ifdef SMP
-static void kick_other_cpu(int pri,int cpuid);
-
 static void
-kick_other_cpu(int pri,int cpuid)
-{	
-	struct pcpu * pcpu = pcpu_find(cpuid);
-	int cpri = pcpu->pc_curthread->td_priority;
+kick_other_cpu(int pri, int cpuid)
+{
+	struct pcpu *pcpu;
+	int cpri;
 
+	pcpu = pcpu_find(cpuid);
 	if (idle_cpus_mask & pcpu->pc_cpumask) {
 		forward_wakeups_delivered++;
 		ipi_selected(pcpu->pc_cpumask, IPI_AST);
 		return;
 	}
 
+	cpri = pcpu->pc_curthread->td_priority;
 	if (pri >= cpri)
 		return;
 
@@ -1147,11 +1154,37 @@
 #endif /* defined(IPI_PREEMPTION) && defined(PREEMPTION) */
 
 	pcpu->pc_curthread->td_flags |= TDF_NEEDRESCHED;
-	ipi_selected( pcpu->pc_cpumask , IPI_AST);
+	ipi_selected(pcpu->pc_cpumask, IPI_AST);
 	return;
 }
 #endif /* SMP */
 
+#ifdef SMP
+static int
+sched_pickcpu(struct thread *td)
+{
+	int best, cpu;
+
+	mtx_assert(&sched_lock, MA_OWNED);
+
+	best = NOCPU;
+	for (cpu = 0; cpu <= mp_maxid; cpu++) {
+		if (CPU_ABSENT(cpu))
+			continue;
+		if (!THREAD_CAN_SCHED(td, cpu))
+			continue;
+	
+		if (best == NOCPU)
+			best = cpu;
+		else if (runq_length[cpu] < runq_length[best])
+			best = cpu;
+	}
+	KASSERT(best != NOCPU, ("no valid CPUs"));
+
+	return (best);
+}
+#endif
+
 void
 sched_add(struct thread *td, int flags)
 #ifdef SMP
@@ -1172,6 +1205,7 @@
 	CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)",
 	    td, td->td_name, td->td_priority, curthread,
 	    curthread->td_name);
+
 	/*
 	 * Now that the thread is moving to the run-queue, set the lock
 	 * to the scheduler's lock.
@@ -1187,28 +1221,39 @@
 		ts->ts_runq = &runq_pcpu[cpu];
 		single_cpu = 1;
 		CTR3(KTR_RUNQ,
-		    "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td, cpu);
-	} else if ((td)->td_flags & TDF_BOUND) {
-		/* Find CPU from bound runq */
-		KASSERT(SKE_RUNQ_PCPU(ts),("sched_add: bound td_sched not on cpu runq"));
+		    "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td,
+		    cpu);
+	} else if (td->td_flags & TDF_BOUND) {
+		/* Find CPU from bound runq. */
+		KASSERT(SKE_RUNQ_PCPU(ts),
+		    ("sched_add: bound td_sched not on cpu runq"));
 		cpu = ts->ts_runq - &runq_pcpu[0];
 		single_cpu = 1;
 		CTR3(KTR_RUNQ,
-		    "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td, cpu);
-	} else {	
+		    "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td,
+		    cpu);
+	} else if (ts->ts_flags & TSF_AFFINITY) {
+		/* Find a valid CPU for our cpuset */
+		cpu = sched_pickcpu(td);
+		ts->ts_runq = &runq_pcpu[cpu];
+		single_cpu = 1;
+		CTR3(KTR_RUNQ,
+		    "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, td,
+		    cpu);
+	} else {
 		CTR2(KTR_RUNQ,
-		    "sched_add: adding td_sched:%p (td:%p) to gbl runq", ts, td);
+		    "sched_add: adding td_sched:%p (td:%p) to gbl runq", ts,
+		    td);
 		cpu = NOCPU;
 		ts->ts_runq = &runq;
 	}
-	
+
 	if (single_cpu && (cpu != PCPU_GET(cpuid))) {
-	        kick_other_cpu(td->td_priority,cpu);
+	        kick_other_cpu(td->td_priority, cpu);
 	} else {
-		
 		if (!single_cpu) {
 			cpumask_t me = PCPU_GET(cpumask);
-			int idle = idle_cpus_mask & me;	
+			cpumask_t idle = idle_cpus_mask & me;
 
 			if (!idle && ((flags & SRQ_INTR) == 0) &&
 			    (idle_cpus_mask & ~(hlt_cpus_mask | me)))
@@ -1222,14 +1267,17 @@
 				maybe_resched(td);
 		}
 	}
-	
+
 	if ((td->td_proc->p_flag & P_NOLOAD) == 0)
 		sched_load_add();
 	runq_add(ts->ts_runq, td, flags);
+	if (cpu != NOCPU)
+		runq_length[cpu]++;
 }
 #else /* SMP */
 {
 	struct td_sched *ts;
+
 	ts = td->td_sched;
 	THREAD_LOCK_ASSERT(td, MA_OWNED);
 	KASSERT((td->td_inhibitors == 0),
@@ -1241,6 +1289,7 @@
 	CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)",
 	    td, td->td_name, td->td_priority, curthread,
 	    curthread->td_name);
+
 	/*
 	 * Now that the thread is moving to the run-queue, set the lock
 	 * to the scheduler's lock.
@@ -1253,21 +1302,19 @@
 	CTR2(KTR_RUNQ, "sched_add: adding td_sched:%p (td:%p) to runq", ts, td);
 	ts->ts_runq = &runq;
 
-	/* 
-	 * If we are yielding (on the way out anyhow) 
-	 * or the thread being saved is US,
-	 * then don't try be smart about preemption
-	 * or kicking off another CPU
-	 * as it won't help and may hinder.
-	 * In the YIEDLING case, we are about to run whoever is 
-	 * being put in the queue anyhow, and in the 
-	 * OURSELF case, we are puting ourself on the run queue
-	 * which also only happens when we are about to yield.
+	/*
+	 * If we are yielding (on the way out anyhow) or the thread
+	 * being saved is US, then don't try be smart about preemption
+	 * or kicking off another CPU as it won't help and may hinder.
+	 * In the YIEDLING case, we are about to run whoever is being
+	 * put in the queue anyhow, and in the OURSELF case, we are
+	 * puting ourself on the run queue which also only happens
+	 * when we are about to yield.
 	 */
-	if((flags & SRQ_YIELDING) == 0) {
+	if ((flags & SRQ_YIELDING) == 0) {
 		if (maybe_preempt(td))
 			return;
-	}	
+	}
 	if ((td->td_proc->p_flag & P_NOLOAD) == 0)
 		sched_load_add();
 	runq_add(ts->ts_runq, td, flags);
@@ -1292,13 +1339,17 @@
 
 	if ((td->td_proc->p_flag & P_NOLOAD) == 0)
 		sched_load_rem();
+#ifdef SMP
+	if (ts->ts_runq != &runq)
+		runq_length[ts->ts_runq - runq_pcpu]--;
+#endif
 	runq_remove(ts->ts_runq, td);
 	TD_SET_CAN_RUN(td);
 }
 
 /*
- * Select threads to run.
- * Notice that the running threads still consume a slot.
+ * Select threads to run.  Note that running threads still consume a
+ * slot.
  */
 struct thread *
 sched_choose(void)
@@ -1314,14 +1365,14 @@
 	td = runq_choose_fuzz(&runq, runq_fuzz);
 	tdcpu = runq_choose(&runq_pcpu[PCPU_GET(cpuid)]);
 
-	if (td == NULL || 
-	    (tdcpu != NULL && 
+	if (td == NULL ||
+	    (tdcpu != NULL &&
 	     tdcpu->td_priority < td->td_priority)) {
 		CTR2(KTR_RUNQ, "choosing td %p from pcpu runq %d", tdcpu,
 		     PCPU_GET(cpuid));
 		td = tdcpu;
 		rq = &runq_pcpu[PCPU_GET(cpuid)];
-	} else { 
+	} else {
 		CTR1(KTR_RUNQ, "choosing td_sched %p from main runq", td);
 	}
 
@@ -1331,13 +1382,17 @@
 #endif
 
 	if (td) {
+#ifdef SMP
+		if (td == tdcpu)
+			runq_length[PCPU_GET(cpuid)]--;
+#endif
 		runq_remove(rq, td);
 		td->td_flags |= TDF_DIDRUN;
 
 		KASSERT(td->td_flags & TDF_INMEM,
 		    ("sched_choose: thread swapped out"));
 		return (td);
-	} 
+	}
 	return (PCPU_GET(idlethread));
 }
 
@@ -1515,4 +1570,65 @@
 void
 sched_affinity(struct thread *td)
 {
+#ifdef SMP
+	struct td_sched *ts;
+	int cpu;
+
+	THREAD_LOCK_ASSERT(td, MA_OWNED);	
+
+	/*
+	 * Set the TSF_AFFINITY flag if there is at least one CPU this
+	 * thread can't run on.
+	 */
+	ts = td->td_sched;
+	ts->ts_flags &= ~TSF_AFFINITY;
+	for (cpu = 0; cpu <= mp_maxid; cpu++) {
+		if (CPU_ABSENT(cpu))
+			continue;
+		if (!THREAD_CAN_SCHED(td, cpu)) {
+			ts->ts_flags |= TSF_AFFINITY;
+			break;
+		}
+	}
+
+	/*
+	 * If this thread can run on all CPUs, nothing else to do.
+	 */
+	if (!(ts->ts_flags & TSF_AFFINITY))
+		return;
+
+	/* Pinned threads and bound threads should be left alone. */
+	if (td->td_pinned != 0 || td->td_flags & TDF_BOUND)
+		return;
+
+	switch (td->td_state) {
+	case TDS_RUNQ:
+		/*
+		 * If we are on a per-CPU runqueue that is in the set,
+		 * then nothing needs to be done.
+		 */
+		if (ts->ts_runq != &runq &&
+		    THREAD_CAN_SCHED(td, ts->ts_runq - runq_pcpu))
+			return;
+
+		/* Put this thread on a valid per-CPU runqueue. */
+		sched_rem(td);
+		sched_add(td, SRQ_BORING);
+		break;
+	case TDS_RUNNING:
+		/*
+		 * See if our current CPU is in the set.  If not, force a
+		 * context switch.
+		 */
+		if (THREAD_CAN_SCHED(td, td->td_oncpu))
+			return;
+
+		td->td_flags |= TDF_NEEDRESCHED;
+		if (td != curthread)
+			ipi_selected(1 << cpu, IPI_AST);
+		break;
+	default:
+		break;
+	}
+#endif
 }

==== //depot/projects/mpsafetty/sys/modules/et/Makefile#2 (text+ko) ====

@@ -1,10 +1,10 @@
 # $DragonFly: src/sys/dev/netif/et/Makefile,v 1.1 2007/10/12 14:12:42 sephe Exp $
-# $FreeBSD: src/sys/modules/et/Makefile,v 1.1 2008/06/20 19:28:33 delphij Exp $
+# $FreeBSD: src/sys/modules/et/Makefile,v 1.2 2008/07/28 17:56:37 antoine Exp $
 
 .PATH: ${.CURDIR}/../../dev/et
 
 KMOD=	if_et
 SRCS=	if_et.c
-SRCS+=	opt_et.h bus_if.h pci_if.h device_if.h miibus_if.h
+SRCS+=	bus_if.h pci_if.h device_if.h miibus_if.h
 
 .include <bsd.kmod.mk>

==== //depot/projects/mpsafetty/usr.bin/ldd/ldd.c#3 (text+ko) ====

@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/usr.bin/ldd/ldd.c,v 1.37 2008/07/21 02:13:14 edwin Exp $");
+__FBSDID("$FreeBSD: src/usr.bin/ldd/ldd.c,v 1.38 2008/07/28 12:49:16 edwin Exp $");
 
 #include <sys/wait.h>
 
@@ -49,15 +49,12 @@
 #include "extern.h"
 
 /*
- * Elf32_xhdr structures can only be used if sys/elf32.h is included, so
- * check for the existence of one of the macros defined in sys/elf32.h.
- *
- * The presense of the ELF32_R_TYPE macro via machine/elf.h has been verified
- * on amd64 6.3, ia64 7.0 and sparc64 7.0.  The absence of the macro has been
- * verified on alpha 6.2.
+ * 32-bit ELF data structures can only be used if the system header[s] declare
+ * them.  There is no official macro for determining whether they are declared,
+ * so check for the existence of one of the 32-macros defined in elf(5).
  */
-#if defined(ELF32_R_TYPE)
-#define ELF32_SUPPORTED
+#ifdef ELF32_R_TYPE
+#define	ELF32_SUPPORTED
 #endif
 
 static int	is_executable(const char *fname, int fd, int *is_shlib,

==== //depot/projects/mpsafetty/usr.sbin/config/config.y#2 (text+ko) ====

@@ -31,6 +31,7 @@
 %type	<str>	Save_id
 %type	<str>	Opt_value
 %type	<str>	Dev
+%token	<str>	PATH
 
 %{
 
@@ -67,7 +68,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)config.y	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.sbin/config/config.y,v 1.79 2007/12/25 06:22:33 imp Exp $
+ * $FreeBSD: src/usr.sbin/config/config.y,v 1.80 2008/07/28 17:11:57 obrien Exp $
  */
 
 #include <assert.h>
@@ -128,6 +129,11 @@
 		|
 	Config_spec SEMICOLON
 		|
+	INCLUDE PATH SEMICOLON {
+		if (incignore == 0)
+			include($2, 0);
+		};
+		|
 	INCLUDE ID SEMICOLON {
 	          if (incignore == 0)
 		  	include($2, 0);

==== //depot/projects/mpsafetty/usr.sbin/config/lang.l#2 (text+ko) ====

@@ -28,7 +28,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)lang.l	8.1 (Berkeley) 6/6/93
- * $FreeBSD: src/usr.sbin/config/lang.l,v 1.45 2007/05/12 19:38:18 wkoszek Exp $
+ * $FreeBSD: src/usr.sbin/config/lang.l,v 1.46 2008/07/28 17:11:57 obrien Exp $
  */
 
 #include <assert.h>
@@ -96,6 +96,7 @@
 
 %}
 ID	[A-Za-z_][-A-Za-z_0-9]*
+PATH	[./][-/.%^A-Za-z_0-9]+
 %START TOEOL
 %%
 {ID}		{
@@ -165,6 +166,11 @@
 				return tok;
 			/* otherwise continue scanning */
 		}
+{PATH}		{
+			BEGIN 0;
+			yylval.str = strdup(yytext);
+			return PATH;
+		}
 .		{	return yytext[0];		}
 
 %%



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