From owner-freebsd-arch@FreeBSD.ORG Thu Mar 10 20:45:05 2011 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09588106566C; Thu, 10 Mar 2011 20:45:05 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 649608FC1D; Thu, 10 Mar 2011 20:45:04 +0000 (UTC) Received: by wyf23 with SMTP id 23so2227258wyf.13 for ; Thu, 10 Mar 2011 12:45:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=bbZ4KTgX0WGbM1E+NkWZRelAEk7If18mGqvSp0cmdzw=; b=xmUDvupPVWi378mKlibc1DDqQZ/qLXuJ5Wm0NQz4obQbzy0bL2yLvuQmOJNhOTHwoj LS8XBKmsptImb8kd8cNZKGRm8Oo+NJejMK67Fq1AUWnotY7FnuAagtYffPUJKNLtklXr YcPZCFGEMfSVznkvEGj/brnoRqi9ycsw3Xy2A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=lnX2vkJDvI0PDfh2KtJD80QBP7f/7Ol+OfgR2nq/w1UkF/Jel5xQmkLJqJOz25YNLK LYsEjIQ0vKAIoJoYWcsTtc4RQBmaw+ODgSFTpgg6ams6RCB8A3uVj5GBUU/5ese66j0P 2ZE9u66CyWthp36sZyGTkNTL22ub6O3Wh/tpQ= MIME-Version: 1.0 Received: by 10.216.244.7 with SMTP id l7mr6396379wer.40.1299789903469; Thu, 10 Mar 2011 12:45:03 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.216.62.130 with HTTP; Thu, 10 Mar 2011 12:45:03 -0800 (PST) In-Reply-To: <201103101528.18987.jhb@freebsd.org> References: <201103101446.37589.jhb@freebsd.org> <201103101528.18987.jhb@freebsd.org> Date: Thu, 10 Mar 2011 12:45:03 -0800 X-Google-Sender-Auth: rPiUz2Ufu6j4Vh0x3ESQl0SKsd4 Message-ID: From: mdf@FreeBSD.org To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-arch@freebsd.org Subject: Re: style(9) rules for nested includes X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2011 20:45:05 -0000 On Thu, Mar 10, 2011 at 12:28 PM, John Baldwin wrote: > On Thursday, March 10, 2011 3:10:58 pm mdf@freebsd.org wrote: >> On Thu, Mar 10, 2011 at 11:46 AM, John Baldwin wrote: >> > On Thursday, March 10, 2011 12:17:28 pm mdf@freebsd.org wrote: >> >> I recall a recent discussion/PR about nested includes in the context >> >> of and being a few of the only ones >> >> allowed. =A0However, I don't see anything in style(9) about this. >> > >> > bde@ is probably the most authoritative. =A0My understanding is that t= he only >> > nested includes allowed in sys/sys/*.h are the two listed above and an= y header >> > that starts with an underscore (sys/_mutex.h, etc.). =A0The underscore= variants >> > were added to allow nested includes when absolutely necessary, but tho= se >> > includes are the bare minimum required to define structures, etc. >> > >> >> Now we come to the reason I ask. =A0I'm working on a patch to change = the >> >> static sysctl code to use the standard SYSININT/SYSUNINIT code rather >> >> than have special treatment in kern_linker.c, but to do this I need t= o >> >> either change quite a few places that include , or >> >> include instead of in sysctl.h, as >> >> the SI_SUB_SYSCTLS value isn't visible otherwise. >> > >> > Hmm, what is the reason to use SYSINIT's instead of a dedicated linker= set? >> >> There's also a minor bug in initialization ordering where a static >> SYSCTL_PROC could use a lock initialized by SX_SYSINIT or MTX_SYSINIT, >> but at runtime module load the sysctl is exposed before the >> SI_SUB_LOCK stage has run, so in theory someone doing sysctl -a would >> crash the kernel on an attempt to lock an uninitialized mtx/sx. =A0We >> saw this happen once at Isilon. > > Hmm, this is a legitimate reason, though I'd be tempted to fix that by ju= st > registering sysctls after sysinit's have been invoked and vice versa on > unload. =A0It seems that would be a simpler fix with far less code churn = and > not having to deal with the nested include mess, etc. I'm not committed to committing this change; I want to see how it looks when finished and run it by -arch. But I hit the nested include file problem first. :-) Changing the sysctl to be after all sysinit I *think* runs into a problem if one has a mix of SYSCTL_ADD_FOO and SYSCTL_FOO on a new static node defined in a loadable module, but I'd have to test that. That is, one would be trying to add a node as a child of a node that hasn't been set up. I think it may work today because the list of child nodes of a static node is actually a separate entity that exists at compile time. Cheers, matthew