Phantom sysctl
mdf at FreeBSD.org
mdf at FreeBSD.org
Mon Nov 15 20:04:06 UTC 2010
On Mon, Nov 15, 2010 at 9:53 AM, Garrett Cooper <yanegomi at gmail.com> wrote:
> According to SYSCTL_INT(9):
>
> The SYSCTL kernel interfaces allow code to statically declare sysctl(8)
> MIB entries, which will be initialized when the kernel module containing
> the declaration is initialized. When the module is unloaded, the sysctl
> will be automatically destroyed.
>
> The sysctl should be reaped when the module is unloaded. My dumb
> test kernel module [1] doesn't seem to do that though (please note
> that the OID test_int_sysctl is created, and not reaped... FWIW it's
> kind of bizarre that test_int_sysctl is created in the first place,
> given what I've seen when SYSCTL_* gets executed):
>
> toaster# kldload ./test_int_sysctl.ko
> toaster# sysctl -a | grep test
> test_int_sysctl: 0
> vfs.nfs_common.realign_test: 0
> debug.test_int_sysctl: 0
> toaster# sysctl test_int_sysctl
> sysctl: unknown oid 'test_int_sysctl'
> toaster# kldunload ./test_int_sysctl.ko
> toaster# sysctl -a | grep test
> test_int_sysctl: 0
> vfs.nfs_common.realign_test: 0
debug.test_int_sysctl did disappear, and that was the sysctl in the module:
SYSCTL_INT(_debug, OID_AUTO, test_int_sysctl, CTLFLAG_RW, &_sysctl, 0,
"Test sysctl OID");
I am not sure where the other test_int_sysctl appeared from, but the
results of "sysctl test_int_sysctl" didn't change from before
kldunload to after.
Thanks,
matthew
> toaster# sysctl test_int_sysctl
> sysctl: unknown oid 'test_int_sysctl'
>
> I've seen this behavior on 8.1-RELEASE (custom kernel, vanilla
> sources), and CURRENT r215254.
> I'm compiling the kernel with SYSCTL_DEBUG (and added some missing
> error checking in the kern_sysctl.c code) to see if I can track down
> the resource issue, but in the meantime if someone more knowledgeable
> has some suggestions for what to do / where I should look, I'm all
> ears.
> Thanks!
> -Garrett
>
> 1. http://pastebin.com/n7d9bH8U
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
>
More information about the freebsd-hackers
mailing list