From owner-freebsd-arch Mon Jan 15 11:14:57 2001 Delivered-To: freebsd-arch@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 8F6A037B401; Mon, 15 Jan 2001 11:14:39 -0800 (PST) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f0FJEdx12466; Mon, 15 Jan 2001 11:14:39 -0800 (PST) Date: Mon, 15 Jan 2001 11:14:39 -0800 From: Alfred Perlstein To: Hajimu UMEMOTO Cc: arch@FreeBSD.org Subject: Re: dynamic vs static sysctls? Message-ID: <20010115111439.C7240@fw.wintelcom.net> References: <20010115100618.Y7240@fw.wintelcom.net> <20010116.033215.41625863.ume@FreeBSD.org> <20010115103757.B7240@fw.wintelcom.net> <20010116.035009.71081161.ume@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010116.035009.71081161.ume@FreeBSD.org>; from ume@FreeBSD.org on Tue, Jan 16, 2001 at 03:50:09AM +0900 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Hajimu UMEMOTO [010115 10:51] wrote: > >>>>> On Mon, 15 Jan 2001 10:37:57 -0800 > >>>>> Alfred Perlstein said: > > bright> Well all the sysctl's I've added have been dynamic, I think the > bright> only reason for the 'static' sysctls is to give sysctl() a > bright> numeric way to get at the sysctls, which isn't very useful > bright> when we have getsysctlbyname(). > > You mean dynamic sysctl is just use of OID_AUTO, right? I thought > SYSCTL_ADD_INT(). > > bright> Using a dynamic sysctl It would reduce the delta by quite a bit. > > Indeed. > > bright> The stuff your patch does seems to allow programs to use the old > bright> (IMHO) depricated sysctl() versus getsysctlbyname() function. > > bright> No one I know wants to use sysctl instead of getsysctlbyname afaik, > bright> however, I would like to know if my opinions are the what we're > bright> aiming for. > > Okey, I'll change to use OID_AUTO. Just do this: static unsigned int nforks = 0; SYSCTL_UINT(_kern, OID_AUTO, nforks, CTLFLAG_RD, &nforks, 0, "number of fork()s since boot"); document the sysctl. :) > > bright> Any other comments? > > One question. How can I detect newly added sysctl? In static, I can > just do by #ifdef OID. Oh, you mean in a kernel module? I think you need to use kernel_sysctl() (from kern/kern_sysctl.c), I'm not sure if it's documented anywhere, if not it'd be nice to have a sysctl(9) manpage. :) > bright> Besideds the way the sysctl is done, the change is pretty nice > bright> to see, but will need mplocking later. > > Do you mean ALLPROC_LOCK(AP_EXCLUSIVE) / ALLPROC_LOCK(AP_RELEASE) ? > If so, I'll move nforks++ between them. No, don't do that, we'll figure out how to lock it later, you may want to use the mp_fixme (mpfixme?) macro near the sysctl variable though. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message