Phantom sysctl

John Baldwin jhb at
Mon Nov 15 18:10:24 UTC 2010

On Monday, November 15, 2010 12:53:57 pm Garrett Cooper 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):

I believe I have seen this work properly before.  Look for 'sysctl' in
sys/kern/kern_linker.c to see the sysctl hooks invoked on kldload and
kldunload to manage these sysctls.  You will probably want to start your
debugging in the unload hook as it sounds like the node is not being
fully deregistered.

John Baldwin

More information about the freebsd-hackers mailing list