Date: Wed, 6 Apr 2011 13:08:20 -0400 From: Ryan Stone <rysto32@gmail.com> To: freebsd-current@freebsd.org Subject: Re: sched_4bsd startup crash trying to run a bound thread on an AP that hasn't started Message-ID: <BANLkTinvisvGiQOs5w-nsxzRVbJUN5%2B5yQ@mail.gmail.com> In-Reply-To: <201104060836.56542.jhb@freebsd.org> References: <BANLkTinSyDaY-06N95n8c1NxOSdEnb5FkQ@mail.gmail.com> <201104060836.56542.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Apr 6, 2011 at 8:36 AM, John Baldwin <jhb@freebsd.org> wrote: > Hummm. =A0Patching 4BSD to use the same route as ULE may be the best solu= tion > for now if that is easiest. =A0Alternatively, you could change 4BSD's > sched_add() to not try to kick other CPUs until smp_started is true. At first I thought that it was a consequence of the way it does CPU affinity, but now I see that it shortcuts if smp_started is not true. How about something like the following for 4BSD? --- sched_4bsd.c (revision 220222) +++ sched_4bsd.c (working copy) @@ -1242,14 +1242,14 @@ } TD_SET_RUNQ(td); - if (td->td_pinned !=3D 0) { + if (smp_started && td->td_pinned !=3D 0) { cpu =3D td->td_lastcpu; ts->ts_runq =3D &runq_pcpu[cpu]; single_cpu =3D 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) { + } else if (smp_started && (td->td_flags & TDF_BOUND)) { /* Find CPU from bound runq. */ KASSERT(SKE_RUNQ_PCPU(ts), ("sched_add: bound td_sched not on cpu runq")); @@ -1258,7 +1258,7 @@ CTR3(KTR_RUNQ, "sched_add: Put td_sched:%p(td:%p) on cpu%d runq", ts, = td, cpu); - } else if (ts->ts_flags & TSF_AFFINITY) { + } else if (smp_started && (ts->ts_flags & TSF_AFFINITY)) { /* Find a valid CPU for our cpuset */ cpu =3D sched_pickcpu(td); ts->ts_runq =3D &runq_pcpu[cpu]; The flow control is a bit awkward because of the multiple affinity/bound cpu cases. If somebody prefers the code to be structured differently I'd be open to suggestions. Ryan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTinvisvGiQOs5w-nsxzRVbJUN5%2B5yQ>