From nobody Wed Feb 22 03:29:30 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 4PM1qb2Vhdz3s9X2; Wed, 22 Feb 2023 03:29:47 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PM1qb0bvLz3pPW; Wed, 22 Feb 2023 03:29:47 +0000 (UTC) (envelope-from rick.macklem@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-pf1-x430.google.com with SMTP id f11so3774177pfe.2; Tue, 21 Feb 2023 19:29:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=YUiQnElUjMCfByvJYfxA4ggNozAPJEKSFoqrdVcOWQ0=; b=Lv9gbtmYquHGwY7IfwwMb2vP4t/GdjPDKVt+C6jn+BcMb4AIprtxtV3esZDOzUheeg F248v2nEPXq0GpPD7V5dA0+o2UgEeU3OjKmpsXRHmny+hjPUgbAVlE5CdQ5hEEtxMrzk TTm4NBwBTMzsvzTcTIfqV8v/HezLI0EO3EfIYRn7woMBJEQhvLskbcanz7sM3LEQj6Jg 7jQ2t4pk+CnCRkPtxVQ9vT5iYAMVnm4VVjeKVrxJdQMF19aOqn77k9LCUWWWpCed72a7 zcPij/Qn7O70U3ETNThPEOEYHhEcM4ZaxT6RLAjeCf1r3xAU+ljm9+88BsOqFIzgvOOi erBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YUiQnElUjMCfByvJYfxA4ggNozAPJEKSFoqrdVcOWQ0=; b=QCAOcllDBptiuwpk5BSsNKT9raE6PB/eEAMmbxJU0gRkz2XC/4j6hZ2TWtfkeN58C6 gDDCJGpN5L4l3KTnJJO9pja4bAU/iDgpB53BK7rXoGoBesTwjmwUMTVc31/bX7ZO7jSk G6F1oJFrx9PWZ0JUl7MzeB/uqph0aBJLxx0im3AWPjJ10L8qqTLqYFX1/s/8Mbbw5Hzw KhXOXgwx7wuuqbkZ+7fALCIeLEfyX1L0fmj7otpiEjawALy7/dp76T+cbrPFoBb7NimE 7QQGUkIWqAAQNBrVu5AOdx/Pe7pQhCdfoK6CliffG8fZTXkGgtKXOgUbw/fd0Bod5rJX FFjQ== X-Gm-Message-State: AO0yUKXQushTNAJL90tNKPTxyTDt3gh/7jr/4K25atIPyUmCD8Pcjx8S O9WpD5rcySm3xq/R5gK6oTpXicHmKrEILS2Vykh85bQXNA== X-Google-Smtp-Source: AK7set+XJutR1z3+6Gfle6wXt37FPARN24M22n6y480JUOFd+w17x+4L1NZ+158d2hFCGzISpom9Eyu+JY+qp8RHh0w= X-Received: by 2002:a05:6a00:2251:b0:5a8:4955:6d8a with SMTP id i17-20020a056a00225100b005a849556d8amr1045241pfu.9.1677036585328; Tue, 21 Feb 2023 19:29:45 -0800 (PST) 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 References: <202302202112.31KLCfQB080359@gitrepo.freebsd.org> In-Reply-To: From: Rick Macklem Date: Tue, 21 Feb 2023 19:29:30 -0800 Message-ID: Subject: Re: git: ef6fcc5e2b07 - main - nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup To: Gleb Smirnoff 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-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4PM1qb0bvLz3pPW X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_FROM(0.00)[] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N On Tue, Feb 21, 2023 at 1:13 PM Gleb Smirnoff wrote: > > CAUTION: This email originated from outside of the University of Guelph. Do not click links or open attachments unless you recognize the sender and know the content is safe. If in doubt, forward suspicious emails to IThelp@uoguelph.ca > > > 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 did that for one of the ones related to nfsd (sys/fs/nfsserver/nfs_fha_new.c). It so happens it doesn't work for this case. If you look at the patch, you'll see that the variable is vnet'd. It happens that it is only malloc'd for prisons other than prison0. (For prison0, it points to a global structure that is not malloc'd and is shared with the NFS client, which is not vnet'd. rick > -- > Gleb Smirnoff >