From nobody Tue Feb 21 21:13:08 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 4PLsT32vSpz3tF0c; Tue, 21 Feb 2023 21:13:11 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from glebi.us (glebi.us [162.251.186.162]) by mx1.freebsd.org (Postfix) with ESMTP id 4PLsT237Sjz4DVh; Tue, 21 Feb 2023 21:13:10 +0000 (UTC) (envelope-from glebius@freebsd.org) Authentication-Results: mx1.freebsd.org; dkim=none; spf=softfail (mx1.freebsd.org: 162.251.186.162 is neither permitted nor denied by domain of glebius@freebsd.org) smtp.mailfrom=glebius@freebsd.org; dmarc=none Received: by glebi.us (Postfix, from userid 1000) id E59DF637B0; Tue, 21 Feb 2023 13:13:08 -0800 (PST) Date: Tue, 21 Feb 2023 13:13:08 -0800 From: Gleb Smirnoff To: Rick Macklem Cc: bz@freebsd.org, jamie@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 Message-ID: References: <202302202112.31KLCfQB080359@gitrepo.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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202302202112.31KLCfQB080359@gitrepo.freebsd.org> X-Spamd-Result: default: False [0.67 / 15.00]; VIOLATED_DIRECT_SPF(3.50)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.83)[-0.827]; MIME_GOOD(-0.10)[text/plain]; RCVD_NO_TLS_LAST(0.10)[]; MLMMJ_DEST(0.00)[dev-commits-src-all@freebsd.org,dev-commits-src-main@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:27348, ipnet:162.251.186.0/24, country:US]; ARC_NA(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; R_SPF_SOFTFAIL(0.00)[~all:c]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[glebius]; RCVD_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[]; DMARC_NA(0.00)[freebsd.org]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Rspamd-Queue-Id: 4PLsT237Sjz4DVh X-Spamd-Bar: / X-ThisMailContainsUnwantedMimeParts: N 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? -- Gleb Smirnoff