Date: Thu, 03 Aug 2017 08:47:48 -0700 From: John Baldwin <jhb@freebsd.org> To: Andriy Gapon <avg@freebsd.org> Cc: freebsd-current@freebsd.org, Hans Petter Selasky <hps@selasky.org>, FreeBSD Hackers <freebsd-hackers@freebsd.org> Subject: Re: order of executing MOD_LOAD and registering module sysctl-s Message-ID: <3503074.NZ5sjsRuYH@ralph.baldwin.cx> In-Reply-To: <158cf433-f2c8-9006-b091-15fe3095c759@FreeBSD.org> References: <62e7ab4d-8956-545e-b204-4fb63cfe5fbf@FreeBSD.org> <2718016.8bPh6cqhGc@ralph.baldwin.cx> <158cf433-f2c8-9006-b091-15fe3095c759@FreeBSD.org>
index | next in thread | previous in thread | raw e-mail
On Thursday, August 03, 2017 09:57:15 AM Andriy Gapon wrote: > On 02/08/2017 18:49, John Baldwin wrote: > > sysctl nodes are created explicitly via linker_file_register_sysctls, not via > > SYSINITs, so you can't order them with respect to other init functions. > > > > I think Andriy's suggestion of doing sysctls "inside" sysinits (so they are > > registered last and unregistered first) is probably better than the current > > state and is a simpler fix than changing all sysctls to use SYSINITs. > > Kostik (kib) suggested a possible valid use-case that depends on the current > order: adding dynamic sysctl-s under static sysctl-s via the module load handler. > He also offered an idea for a possible solution: holding the modules lock in the > shared mode (MOD_SLOCK) around calls to sysctl-s registered from modules. Yes, that could work. You'd need a way to "tag" sysctls as being module sysctls vs non-module sysctls. Another possiblity would be to make two passes over sysctls when loading/unloading modules where you have a "disabled" flag or some such. During load you would set this flag when doing sysctl_register_oid for the static nodes and then do a second pass after the SYSINITs to clear all the disabled flags. During unload you would do this in reverse with an early pass before SYSUNINITs to set "disabled" on all the static nodes for the kld. -- John Baldwinhome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3503074.NZ5sjsRuYH>
