From owner-freebsd-current@freebsd.org Thu Aug 3 16:34:19 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D28F0DC71DF; Thu, 3 Aug 2017 16:34:19 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AF72514EC; Thu, 3 Aug 2017 16:34:19 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id AB50810AB01; Thu, 3 Aug 2017 12:34:10 -0400 (EDT) From: John Baldwin To: Andriy Gapon Cc: freebsd-current@freebsd.org, Hans Petter Selasky , FreeBSD Hackers Subject: Re: order of executing MOD_LOAD and registering module sysctl-s Date: Thu, 03 Aug 2017 08:47:48 -0700 Message-ID: <3503074.NZ5sjsRuYH@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.1-STABLE; KDE/4.14.30; amd64; ; ) 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> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Thu, 03 Aug 2017 12:34:10 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Aug 2017 16:34:19 -0000 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 Baldwin