From nobody Wed Feb 22 01:52:05 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 4PLzg10Gg0z3tn3Q; Wed, 22 Feb 2023 01:52:13 +0000 (UTC) (envelope-from zlei@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PLzg06smhz3N7N; Wed, 22 Feb 2023 01:52:12 +0000 (UTC) (envelope-from zlei@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677030733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oC/VADfMSoI124Ub1CXWatWYSzTwE58Fbse8lL9GGR4=; b=ES5nWWFEfwgVqZ+2KBejIUmCMT1K62z8MeEovphLBA2elHmShLfzOHed0gzFh0hIK/Mrdz L6KLqr+93YqsUNCEJ4xJQEs22aPcwUdcal5lAMSUDza+XSaCCB7KQL6g8wqcf9pbQR9ybc bSo187klJFI4mTqHlyk4OkM1HUKuVRGCxT/llfNPYiWxmsSA+wccUWNyExam81flIhktA9 xOffvEui6d4k8WIdforUkCIi0eb6HhWVOpXQSFgcwZf36br4xT6rdSqHAvTBgetyJGVToN 4NRoFvzMEZcdx2q7DgsHUhRnUjAOygU/PTpOL8ofb0If1ucwupGYgGFpaYg9Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677030733; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oC/VADfMSoI124Ub1CXWatWYSzTwE58Fbse8lL9GGR4=; b=TpFiw+uc5Namt+PMtJSxnOz2yaVoRiT7rhRtkSGvbKeDbqLg2hBGIc3dfcUe9zG6KKsnht YmztgcXODlZaKc4IrcRHPZIEX+569e6kT+s1yqNEauJ02kV+23Tii7s6Cik+UJu0uQoAB0 KCFyqniUV25bHounltFfO5VDEArcTSgPy7sq30/+sbSMIPOGcblMn5031/fj2ICJxwsxXu j30JaPo4qN2s8F0CBa7hm0fwnttku8BF7QKNZmWQwZDmzQLWZkJ+S8i0uDJB23Xh647nNQ QcluC1stgmpbZEwv9Gdq8KS1UQ+JO9UcRp1U6IYcI554IuKrgq19BK0hOs3l/A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677030733; a=rsa-sha256; cv=none; b=vGNa53u1DGENWOU/F8SGmB4lvjmqYCtrqoUgYdTDm/jcYxKvLLhDaJzC1FL5UOkMRo8vSh q+XNZNCRM5ubuPd9yfRoosJj8ouq1EfTWD1QeAiHsyfHCD6a8tjaOKm/OEKp9v0hkMzgVt fNqQFyueS6orzyCP6sQF6l8Bccua0QWbDjkWk8W77+GQix6YrwFwUmytalFwlc+7aBv65Q ye0bm/L9+RwEKxNHA2+Ax3Vd1Q33Ovmp+bPDq90QUtWUgw+y/q60aGqDyVMr4cbTlgWB6Q w3j1UgYcBeb/9ond+W52tcrGhglStQgsodXygY8HLDd1FS5cNRVQEgWoZS40Wg== Received: from smtpclient.apple (ns1.oxydns.net [45.32.91.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: zlei/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PLzfy5wQ2zly1; Wed, 22 Feb 2023 01:52:10 +0000 (UTC) (envelope-from zlei@FreeBSD.org) Content-Type: text/plain; charset=us-ascii 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 (Mac OS X Mail 16.0 \(3696.120.41.1.2\)) Subject: Re: git: ef6fcc5e2b07 - main - nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup From: Zhenlei Huang In-Reply-To: Date: Wed, 22 Feb 2023 09:52:05 +0800 Cc: Rick Macklem , bz@freebsd.org, jamie@freebsd.org, src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <6AE3CB33-555F-444B-8263-70FDCA550798@FreeBSD.org> References: <202302202112.31KLCfQB080359@gitrepo.freebsd.org> To: Gleb Smirnoff X-Mailer: Apple Mail (2.3696.120.41.1.2) X-ThisMailContainsUnwantedMimeParts: N > On Feb 22, 2023, at 5:13 AM, Gleb Smirnoff = wrote: >=20 > On Mon, Feb 20, 2023 at 09:12:41PM +0000, Rick Macklem wrote: > R> nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup > R> =20 > 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> =20 > 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. >=20 > 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: >=20 > static globalfoo; > VNET_DEFINE_STATIC(foobar); >=20 > static void > foo_vnet_init() > { > initialize(V_foobar); > if (IS_DEFAULT_VNET(curvnet)) > initialize(globalfoo); > =09 > } > VNET_SYSINIT(foo_vnet_init, ....) >=20 > We can do a separate init of global state and separate of per-VNET: >=20 > static globalfoo; > static void > foo_init() > { > initialize(globalfoo); > } > SYSINIT(foo_init, ....) >=20 > VNET_DEFINE_STATIC(foobar); > static void > foo_vnet_init() > { > initialize(V_foobar); > } >=20 > This allows to: >=20 > * 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 >=20 > What do you guys think? >=20 > --=20 > Gleb Smirnoff +1 for that. Also be aware the init order of VNET_SYSINIT, when VIMAGE is not = enabled. Best regards, Zhenlei