From owner-freebsd-current@FreeBSD.ORG Wed Apr 6 17:08:22 2011 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 915191065670 for ; Wed, 6 Apr 2011 17:08:22 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from mail-ey0-f182.google.com (mail-ey0-f182.google.com [209.85.215.182]) by mx1.freebsd.org (Postfix) with ESMTP id 2407B8FC1C for ; Wed, 6 Apr 2011 17:08:21 +0000 (UTC) Received: by eyg7 with SMTP id 7so570291eyg.13 for ; Wed, 06 Apr 2011 10:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=4AKPanPxzomJlB2mnBK9+L3e8SLZ7If7BTtGu3CKIuc=; b=DhWVwmomE27Wq6A/6skL/d8lsS5ljxVyQOhktJWBdeVcLTp6pkOZvoKJlVSJxjqXaG ExLSEIzch3HrsVrA+v3rGe45k4Em3s/U8KMu/0OFMNhb2LwBzbZeNLeDE1sZp3vh6VMk 3xWg9YMry838A6SQolFSEGFZeeZAzhqpXe2iE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=QIlbW9cU3MRKZ6OD4N1Pi8St4VPR3A6GufwUG3k2WLLOnLPMqaaYTMlD4Q3NEmCv9Y wdk11PjQ8LKi/naOImJYws2pfClmMFhqMQkuuBC/ZbFfd7/GoazmirajbXvoUgD5no0g wps0dcTeLD5DEnjaxZH5fDaoHr+D2Q+BJvr8w= MIME-Version: 1.0 Received: by 10.213.105.204 with SMTP id u12mr928117ebo.130.1302109700896; Wed, 06 Apr 2011 10:08:20 -0700 (PDT) Received: by 10.213.112.212 with HTTP; Wed, 6 Apr 2011 10:08:20 -0700 (PDT) In-Reply-To: <201104060836.56542.jhb@freebsd.org> References: <201104060836.56542.jhb@freebsd.org> Date: Wed, 6 Apr 2011 13:08:20 -0400 Message-ID: From: Ryan Stone To: freebsd-current@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: sched_4bsd startup crash trying to run a bound thread on an AP that hasn't started X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2011 17:08:22 -0000 On Wed, Apr 6, 2011 at 8:36 AM, John Baldwin 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