Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jun 2014 09:44:17 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-current@freebsd.org
Cc:        Hans Petter Selasky <hps@selasky.org>
Subject:   Re: [RFC] Huge sysctl patch for the kernel coming - work in progress
Message-ID:  <201406180944.17762.jhb@freebsd.org>
In-Reply-To: <53A179D5.8020604@selasky.org>
References:  <53A179D5.8020604@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, June 18, 2014 7:36:53 am Hans Petter Selasky wrote:
> Hi,
> 
> Sometimes sysctl's default value needs to be setup at boot time and not 
> when the rc.d/sysctl is running. Currently this is done by having two 
> statements in the kernel:
> 
> TUNABLE_INT("net.graph.mppe.log_max_rekey", &mppe_log_max_rekey);
> SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RW,
> 
> I want to simplify this to:
> 
> SYSCTL_INT(_net_graph_mppe, OID_AUTO, log_max_rekey, CTLFLAG_RWTUN,
> 
> In other words if the existing CTLFLAG_TUN is set, the sysctl will 
> automatically be pre-loaded with values from /boot/loader.conf.
> 
> The reason we don't want the current approach is:
> 
> 1) It duplicates the sysctl path in the TUNABLE statement.
> 2) It does not work very well for dynamically attached sysctls. There is 
> a lot of code overhead computing the TUNABLE() path before the TUNABLE() 
> can be fetched.
> 
> Here is a work in progress:
> 
> http://home.selasky.org:8192/sysctl_tunable.diff
> 
> In most cases my patch is fine, but in some other cases I need some 
> input, like in the VM subsystem when doing init, I'm not sure if the 
> SYSINIT() for subsystem SI_SUB_KMEM, which sysctl's are using, has 
> already been executed.

I think this is a good idea, but it's also true you can just leave separate
TUNABLE_ statements without setting the CTLFLAG_TUN flag for cases you aren't
sure about for now.  It probably makes sense to do these changes in stages.

I was going to suggest using sbuf() for building the tunable name, but that
doesn't work since you have to build it in reverse.

-- 
John Baldwin



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