Date: Mon, 28 Jul 2008 12:24:33 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 146105 for review Message-ID: <200807281224.m6SCOXkf096287@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=146105 Change 146105 by jhb@jhb_zion on 2008/07/28 12:23:33 Grrrr, fork() clears td_flags after sched_fork() is called, so the TDF_AFFINITY flag was getting lost for new child processes. Move the flag into a new ts_flags field instead. Affected files ... .. //depot/projects/smpng/sys/kern/sched_4bsd.c#82 edit Differences ... ==== //depot/projects/smpng/sys/kern/sched_4bsd.c#82 (text+ko) ==== @@ -91,13 +91,16 @@ 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 */ }; /* flags kept in td_flags */ #define TDF_DIDRUN TDF_SCHED0 /* thread actually ran. */ #define TDF_BOUND TDF_SCHED1 /* Bound to one CPU. */ -#define TDF_AFFINITY TDF_SCHED2 /* Has a non-"full" CPU set. */ + +/* 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) @@ -738,9 +741,9 @@ childtd->td_estcpu = td->td_estcpu; childtd->td_lock = &sched_lock; childtd->td_cpuset = cpuset_ref(td->td_cpuset); - childtd->td_flags |= (td->td_flags & TDF_AFFINITY); ts = childtd->td_sched; bzero(ts, sizeof(*ts)); + ts->ts_flags |= (td->td_sched->ts_flags & TSF_AFFINITY); } void @@ -1232,7 +1235,7 @@ 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_AFFINITY) { + } else if (ts->ts_flags & TSF_AFFINITY) { /* Find a valid CPU for our cpuset */ cpu = sched_pickcpu(td); ts->ts_runq = &runq_pcpu[cpu]; @@ -1576,15 +1579,15 @@ THREAD_LOCK_ASSERT(td, MA_OWNED); /* - * Set the TDF_AFFINITY flag if there is at least one CPU this + * Set the TSF_AFFINITY flag if there is at least one CPU this * thread can't run on. */ - td->td_flags &= ~TDF_AFFINITY; + ts->ts_flags &= ~TSF_AFFINITY; for (cpu = 0; cpu <= mp_maxid; cpu++) { if (CPU_ABSENT(cpu)) continue; if (!THREAD_CAN_SCHED(td, cpu)) { - td->td_flags |= TDF_AFFINITY; + ts->ts_flags |= TSF_AFFINITY; break; } } @@ -1592,7 +1595,7 @@ /* * If this thread can run on all CPUs, nothing else to do. */ - if (!(td->td_flags & TDF_AFFINITY)) + if (!(ts->ts_flags & TSF_AFFINITY)) return; /* Pinned threads and bound threads should be left alone. */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807281224.m6SCOXkf096287>