Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jan 2001 22:33:42 -0800
From:      Alfred Perlstein <bright@wintelcom.net>
To:        Kirk McKusick <mckusick@mckusick.com>
Cc:        arch@FreeBSD.ORG
Subject:   Re: dynamic vs static sysctls?
Message-ID:  <20010115223342.L7240@fw.wintelcom.net>
In-Reply-To: <200101152345.PAA22257@beastie.mckusick.com>; from mckusick@mckusick.com on Mon, Jan 15, 2001 at 03:45:35PM -0800
References:  <20010115103757.B7240@fw.wintelcom.net> <200101152345.PAA22257@beastie.mckusick.com>

next in thread | previous in thread | raw e-mail | index | archive | help
* Kirk McKusick <mckusick@mckusick.com> [010115 20:23] wrote:
> 	Date: Mon, 15 Jan 2001 10:37:57 -0800
> 	From: Alfred Perlstein <bright@wintelcom.net>
> 	To: Hajimu UMEMOTO <ume@FreeBSD.ORG>
> 	Cc: arch@FreeBSD.ORG
> 	Subject: dynamic vs static sysctls?
> 
> 	[moved to -arch]
> 
> 	...
> 
> 	No one I know wants to use sysctl instead of getsysctlbyname afaik,
> 	however, I would like to know if my opinions are the what we're
> 	aiming for.
> 
> 	...
> 
> 	-- 
> 	-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
> 	"I have the heart of a child; I keep it in a jar on my desk."
> 
> I have an example where sysctl is still useful. In my work on a
> background version of fsck, I have used sysctl to allow me to
> pass information into the kernel that I want to have updated in
> the filesystem. In the case of lost blocks, there may be hundreds
> or even thousands of blocks that need to be put back into the
> bit maps. Each non-contiguous block is passed in separately
> which results in hundreds or thousands of sysctl calls. I want
> to do one call to sysctlnametomib (a new, but obviously trivial
> function) to return the numeric mib, and then use that mib on all
> the subsequent sysctl calls. That dramatically cuts down on the
> time it takes to return the blocks since I do not have to translate
> the same name repeatedly (which takes far longer than the block
> release itself). I would think that this might be an issue for
> any application that uses sysctl to get/set the same information
> repeatedly.

I like this optimization, the only problem is that there's a chance
that a dynamic sysctl may disapear out from under you, and even
worse, replaced by an unrelated writeable one.

Perhaps you should include a generation count within the sysctl to
prevent this sort of potential problem?  So besideds passing the
sysctl number, you would include a generation count and error out
if both numbers didn't match?

-- 
-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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010115223342.L7240>