From nobody Wed Feb 22 01:43:07 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PLzSf5WwBz3tmqn; Wed, 22 Feb 2023 01:43:14 +0000 (UTC) (envelope-from jamie@freebsd.org) Received: from gritton.org (gritton.org [162.220.209.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "gritton.org", Issuer "gritton.org" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PLzSf36Qsz3MjW; Wed, 22 Feb 2023 01:43:14 +0000 (UTC) (envelope-from jamie@freebsd.org) Authentication-Results: mx1.freebsd.org; none Received: from gritton.org ([127.0.0.3]) (authenticated bits=0) by gritton.org (8.16.1/8.16.1) with ESMTPA id 31M1h7CQ019415; Tue, 21 Feb 2023 17:43:07 -0800 (PST) (envelope-from jamie@freebsd.org) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Date: Tue, 21 Feb 2023 17:43:07 -0800 From: James Gritton To: Gleb Smirnoff Cc: Rick Macklem , bz@freebsd.org, src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: ef6fcc5e2b07 - main - nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup In-Reply-To: References: <202302202112.31KLCfQB080359@gitrepo.freebsd.org> User-Agent: Roundcube Webmail/1.4.11 Message-ID: X-Sender: jamie@freebsd.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4PLzSf36Qsz3MjW X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:30247, ipnet:162.220.208.0/22, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On 2023-02-21 13:13, Gleb Smirnoff wrote: > On Mon, Feb 20, 2023 at 09:12:41PM +0000, Rick Macklem wrote: > R> nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup > R> > R> Commit ed03776ca7f4 enabled the vnet front end macros. > R> As such, for kernels built with the VIMAGE option will malloc > R> data and initialize locks on a per-vnet basis, typically > R> via a VNET_SYSINIT(). > R> > R> This patch adds VNET_SYSUNINIT() macros to do the frees > R> of the per-vnet malloc'd data and destroys of per-vnet > R> locks. It also removes the mtx_lock/mtx_unlock calls > R> from nfsrvd_cleancache(), since they are not needed. > > In the netinet/netinet6/TCP/UDP we came to a style where we avoid > using IS_DEFAULT_VNET(). Instead doing global and per-vnet init > in the same function: > > static globalfoo; > VNET_DEFINE_STATIC(foobar); > > static void > foo_vnet_init() > { > initialize(V_foobar); > if (IS_DEFAULT_VNET(curvnet)) > initialize(globalfoo); > > } > VNET_SYSINIT(foo_vnet_init, ....) > > We can do a separate init of global state and separate of per-VNET: > > static globalfoo; > static void > foo_init() > { > initialize(globalfoo); > } > SYSINIT(foo_init, ....) > > VNET_DEFINE_STATIC(foobar); > static void > foo_vnet_init() > { > initialize(V_foobar); > } > > This allows to: > > * guarantee that global state is initialized earlier than per-vnet > * separate all global vars from all vnet vars, and keep them together, > easier to maintain > * makes it easier to write VNET_SYSUNINIT() that is complement to > VNET_SYSINIT() > * makes it easier to write SYSUNINIT(), if module is unloadable > * sometimes global SYSINIT cab be avoided, if a static initializer is > enough > > What do you guys think? I'm all for that, just on the first point alone. - Jamie