From nobody Wed Jun 15 16:11:21 2022 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 7834485B655; Wed, 15 Jun 2022 16:11:25 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail2.ambrisko.com (mail2.ambrisko.com [70.91.206.91]) by mx1.freebsd.org (Postfix) with ESMTP id 4LNVfh3JRjz4sfX; Wed, 15 Jun 2022 16:11:24 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) IronPort-SDR: rFccK8od7GnTJmPYbEWqO66MQHCCDthq3wNivXtAHdWNqyl1WWq2f5lVbEZSR9dtlNv8XgFYf5 egpx03lrFerKiffBtbbK0yIWm4tXU+mWc= X-Ambrisko-Me: Yes IronPort-Data: A9a23:iHaVaK/ffHvfKP2+JPUJDrUDBH6TJUtcMsCJ2f8bNWPcYEJGY0x3z WMbWzuAbPuLM2T0c4t2Po629xgD7ZKEx9RqTwE+qClgHilAwSbn6XR1DatR0we6dJCroHqKY 6zyU/GYRCwOZia0SiqFadANk1EtjMlkeZKsUIYoCggpLeNVYH9JZSBLwobVsaY06TSNOD5hj PupyyHp1P9J7BYvWo4cw/rrRBqCJ50eshtA1rA1TagjUFMzCxD5pX/CTJxdIUcUQqEMdgK7b +fF0Lyj+GrduR4oAMmkibX8NEYNR9Y+PyDX2yAQAvbyxEEE/ETe0Y5jXBYYQU5SgS+IhNN24 NxIv4axUgQueKbLnYzxVjEFSHgiZPcuFLjvZCLXXdao51bceD7nxPBrDV0qMJcD0uhtDGxE7 vBeLyoCBjiGhe2r0rO4YuZpj8UnasLsOes3s3Rq1zDCDvEOT4rOTq/R6ZlfxjhYrtpLFP3dY 8ccQSdoYwnNZwVPfFweYLoykfntjX76djxEsxeOv6Fy6mzX5AJr3bXnK9aTfcaFLe1Zk1jdr WXD+mXlGVQBLtfazDOE9FqinOLClzj3HoUIG9WQ3e8su1aT22YeEgE+XkCwoeSzh1SiHdlYL iQpFoAGxUQp3FemVMfwRUf+qXuOpB8HWN0WGOo/gDxhA5H8u26xblXohBYYADD/nMNpFzEsy HGTmNblWW5mvLGPEyvP/7KetzKpOi89JGoIfy4fTgxD6N7m+dlhghXKR9dlMai0ktylRGmpk mzS9HAz1+cJkMoG96Sn5lSb0TiikYfEE1wu7QLNU2P7sg4gPNy5Z5al4ETw5OpbKNrLVUGIu XUJwpDM7O0HAZyXujaKReEBQOOg6/qfamSOiFtlBZg69DOF8nupZ4FL4zY4L0Bsa55WdTjsa U7VmAVQ+J4DYSPzPPMvO9q8Up14w7LhGNLpUuHvQuBPOpUhJhWa+CxOZFKL2zy/mkYbjqxia 4yQdtyhDChGBP0/nia2XeoUzZQi2js6mTHIXZn+whmqjeieaXqSRetXOVeCdLpgvqKCvAjP9 d9bccKPwQ9eS+75JCLQ9NdLf1wNKHE6A7HwqtBWJrPbe1s6QDl5Bq+D264ldqxkg79Rx7XB8 XyKU0NFzEby2C/cIgKQZ3E/ML7iAcRloXQgMXB+NFqkwSJ7M52i9rkSbcFxdLwt7u14zvkyR P4AIp3SDvNKQzXB2jIccZit8dQ7JUjz3VqDb3i/fTwyX598XAiYqNbrczzm+DQKEifq59A1p Ket11+DTJcOL+i44B06tB57I4uNgEUg IronPort-HdrOrdr: A9a23:XJVwLq4wDzhcMNhimwPXwMjXdLJyesId70hD6qm+c31om+ij5q eTdZUgpHvJYVkqNE3I9eruBEDEewK7yXcX2/h1AV7BZniEhILAFugLhubfKn/bak/DH4VmtZ uIHZIRNDXBZ2IRsfrH Received: from server2.ambrisko.com (HELO internal.ambrisko.com) ([192.168.1.2]) by ironport2.ambrisko.com with ESMTP; 15 Jun 2022 08:04:50 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by internal.ambrisko.com (8.17.1/8.17.1) with ESMTPS id 25FGBLJD070992 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 15 Jun 2022 09:11:22 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) X-Authentication-Warning: internal.ambrisko.com: Host localhost [127.0.0.1] claimed to be ambrisko.com Received: (from ambrisko@localhost) by ambrisko.com (8.17.1/8.17.1/Submit) id 25FGBLfW070991; Wed, 15 Jun 2022 09:11:21 -0700 (PDT) (envelope-from ambrisko) Date: Wed, 15 Jun 2022 09:11:21 -0700 From: Doug Ambrisko To: Cy Schubert Cc: Mateusz Guzik , Doug Ambrisko , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org, Rick Macklem Subject: Re: git: 6468cd8e0ef9 - main - mount: add vnode usage per file system with mount -v Message-ID: References: <202206131457.25DEvJDU044469@gitrepo.freebsd.org> <20220615030833.79F9A9B@slippy.cwsent.com> <20220615140514.77BEDD7@slippy.cwsent.com> <20220615160912.6E86A202@slippy.cwsent.com> 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: <20220615160912.6E86A202@slippy.cwsent.com> X-Rspamd-Queue-Id: 4LNVfh3JRjz4sfX X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of ambrisko@ambrisko.com has no SPF policy when checking 70.91.206.91) smtp.mailfrom=ambrisko@ambrisko.com X-Spamd-Result: default: False [-1.72 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.72)[-0.718]; FREEFALL_USER(0.00)[ambrisko]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; DMARC_NA(0.00)[ambrisko.com]; AUTH_NA(1.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; MLMMJ_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; R_SPF_NA(0.00)[no SPF record]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:7922, ipnet:70.88.0.0/14, country:US]; FREEMAIL_CC(0.00)[gmail.com,freebsd.org,uoguelph.ca]; MID_RHS_MATCH_FROM(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On Wed, Jun 15, 2022 at 09:09:12AM -0700, Cy Schubert wrote: | Thanks. This fixes it. 16 simultaneous tar cf /dev/null /usr/obj on three | separate NFS clients: | | Server: | Clients OpenOwner Opens LockOwner Locks | Delegs | 3 48 54 0 0 | 0 | Layouts | 0 | | The load on the NFS server is ~ 0.5 to 2 on a four core machine with CPU | sys busy between 2% and 30%. Prior to this CPU sys was pegged at close to | 100% with a load of 18. The regression has been resolved. Thanks. Thanks for the confirmation. Seems like statfs is used by a lot of things. Doug A. | In message , Doug Ambrisko writes: | > On Wed, Jun 15, 2022 at 07:23:51AM -0700, Doug Ambrisko wrote: | > | On Wed, Jun 15, 2022 at 07:05:14AM -0700, Cy Schubert wrote: | > | | Can we revert this, please. It breaks NFSv4. | > | | > | It would be nice if you could try the proposed partial revert. | > | I'm planning to commit that shortly. | > | > It is in ce00b11940ab. | > | > Please let me know how that works. | > | > Thanks, | > | > Doug A. | > | | In message <20220615030833.79F9A9B@slippy.cwsent.com>, Cy Schubert writes | > : | > | | > In message ail.c | > | | > om> | > | | > , Mateusz Guzik writes: | > | | > > On 6/13/22, Doug Ambrisko wrote: | > | | > > > On Mon, Jun 13, 2022 at 06:43:31PM +0200, Mateusz Guzik wrote: | > | | > > > | On 6/13/22, Doug Ambrisko wrote: | > | | > > > | > The branch main has been updated by ambrisko: | > | | > > > | > | > | | > > > | > URL: | > | | > > > | > | > | | > > > https://cgit.FreeBSD.org/src/commit/?id=6468cd8e0ef9d1d3331e9de26cd | > 2be59b | > | | > c7 | > | | > > 78494 | > | | > > > | > | > | | > > > | > commit 6468cd8e0ef9d1d3331e9de26cd2be59bc778494 | > | | > > > | > Author: Doug Ambrisko | > | | > > > | > AuthorDate: 2022-06-13 14:56:38 +0000 | > | | > > > | > Commit: Doug Ambrisko | > | | > > > | > CommitDate: 2022-06-13 14:56:38 +0000 | > | | > > > | > | > | | > > > | > mount: add vnode usage per file system with mount -v | > | | > > > | > | > | | > > > | > This avoids the need to drop into the ddb to figure out vno | > de | > | | > > > | > usage per file system. It helps to see if they are or are | > not | > | | > > > | > being freed. Suggestion to report active vnode count was f | > rom | > | | > > > | > kib@ | > | | > > > | > | > | | > > > | > Reviewed by: kib | > | | > > > | > Differential Revision: https://reviews.freebsd.org/D35436 | > | | > > > | > --- | > | | > > > | > sbin/mount/mount.c | 7 +++++++ | > | | > > > | > sys/kern/vfs_mount.c | 12 ++++++++++++ | > | | > > > | > sys/sys/mount.h | 4 +++- | > | | > > > | > 3 files changed, 22 insertions(+), 1 deletion(-) | > | | > > > | > | > | | > > > | > diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c | > | | > > > | > index 79d9d6cb0caf..bd3d0073c474 100644 | > | | > > > | > --- a/sbin/mount/mount.c | > | | > > > | > +++ b/sbin/mount/mount.c | > | | > > > | > @@ -692,6 +692,13 @@ prmount(struct statfs *sfp) | > | | > > > | > xo_emit("{D:, }{Lw:fsid}{:fsid}", fsidb | > uf); | > | | > > > | > free(fsidbuf); | > | | > > > | > } | > | | > > > | > + if (sfp->f_nvnodelistsize != 0 || sfp->f_avnode | > count != | > | | > > 0) { | > | | > > > | > + xo_open_container("vnodes"); | > | | > > > | > + xo_emit("{D:, | > | | > > > | > }{Lwc:vnodes}{Lw:count}{w:count/%ju}{Lw:active}{:active/%ju}", | > | | > > > | > + (uintmax_t)sfp->f_nvnodelistsize, | > | | > > > | > + (uintmax_t)sfp->f_avnodecount); | > | | > > > | > + xo_close_container("vnodes"); | > | | > > > | > + } | > | | > > > | > } | > | | > > > | > xo_emit("{D:)}\n"); | > | | > > > | > } | > | | > > > | > diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c | > | | > > > | > index 71a40fd97a9c..e3818b67e841 100644 | > | | > > > | > --- a/sys/kern/vfs_mount.c | > | | > > > | > +++ b/sys/kern/vfs_mount.c | > | | > > > | > @@ -2610,6 +2610,8 @@ vfs_copyopt(struct vfsoptlist *opts, cons | > t char | > | | > > > *name, | > | | > > > | > void *dest, int len) | > | | > > > | > int | > | | > > > | > __vfs_statfs(struct mount *mp, struct statfs *sbp) | > | | > > > | > { | > | | > > > | > + struct vnode *vp; | > | | > > > | > + uint32_t count; | > | | > > > | > | > | | > > > | > /* | > | | > > > | > * Filesystems only fill in part of the structure for u | > pdates, | > | | > > we | > | | > > > | > @@ -2624,6 +2626,16 @@ __vfs_statfs(struct mount *mp, struct st | > atfs | > | | > > > *sbp) | > | | > > > | > sbp->f_version = STATFS_VERSION; | > | | > > > | > sbp->f_namemax = NAME_MAX; | > | | > > > | > sbp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; | > | | > > > | > + sbp->f_nvnodelistsize = mp->mnt_nvnodelistsize; | > | | > > > | > + | > | | > > > | > + count = 0; | > | | > > > | > + MNT_ILOCK(mp); | > | | > > > | > + TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { | > | | > > > | > + if (vrefcnt(vp) > 0) /* racy but does not matte | > r */ | > | | > > > | > + count++; | > | | > > > | > + } | > | | > > > | > + MNT_IUNLOCK(mp); | > | | > > > | > + sbp->f_avnodecount = count; | > | | > > > | > | > | | > > > | | > | | > > > | libc uses statfs for dir walk (see gen/fts.c), most notably find | > | | > > > | immediately runs into it. As such the linear scan by default is a | > | | > > > | non-starter. | > | | > > > | | > | | > > > | I don't know if mount is the right place to dump this kind of inf | > o to | > | | > > > | begin with, but even so, it should only happen with a dedicated f | > lag. | > | | > > > | | > | | > > > | As statfs does not take any flags on its own, there is no way to | > | | > > > | prevent it from doing the above walk. Perhaps a dedicated sysctl | > which | > | | > > > | takes mount point id could do the walk instead, when asked. | > | | > > > | | > | | > > > | Short of making the walk optional I'm afraid this will have to be | > | | > > > reverted. | > | | > > > | > | | > > > Just to be clear, this isn't breaking things but is not optimal for | > | | > > > things that don't need this extra info. | > | | > > > | > | | > > | > | | > > It's not "not optimal", it's a significant overhead which taxes | > | | > > frequent users which don't benefit from it. | > | | > | > | | > Indeed this is not optimal. Since this revision NFSv4 performance has | > | | > tanked. An installworld over NFSv4 which used to take approximately 15 | > | | > minutes took all night, not even finishing by morning. The NFS server, | > a 4 | > | | > core machine, had a load average of 18 with three NFS clients attemptin | > g | > | | > installworld with nfsd using over 90% of the cycles on the machine. I w | > as | > | | > able to reproduce the problem by running a series of tar cf /dev/null | > | | > /usr/obj in parallel, on a single NFSv4 client to essentially DoS the N | > FSv4 | > | | > server. | > | | > | > | | > The workaround was to fall back to NFSv3, which was unaffected by this | > | | > revision. | > | | > | > | | > I reached out to our resident NFS person (rmacklem@) who suggested | > | | > reverting this revision, restoring the network to pre-regression state. | > | | > | > | | > > | > | | > > For more data I plugged dtrace -n 'fbt::__vfs_statfs:entry { | > | | > > @[execname] = count(); }' while package building, then i got tons of | > | | > > hits: | > | | > > [snip] | > | | > > expr 13992 | > | | > > install 14090 | > | | > > dirname 14921 | > | | > > mv 17404 | > | | > > ghc-stage1 17577 | > | | > > grep 18998 | > | | > > xgcc 23832 | > | | > > cpp 29282 | > | | > > cc1 36961 | > | | > > sh 70575 | > | | > > rm 73904 | > | | > > ld.lld 87784 | > | | > > sed 88803 | > | | > > c++ 98175 | > | | > > cat 115811 | > | | > > cc 449725 | > | | > > | > | | > [...] | > | | > > -- | > | | > > Mateusz Guzik | > | | > > | > | | > | > | | > | > | | > -- | > | | > Cheers, | > | | > Cy Schubert | > | | > FreeBSD UNIX: Web: http://www.FreeBSD.org | > | | > NTP: Web: https://nwtime.org | > | | > | > | | > e**(i*pi)+1=0 | > | | > | > | | > | > | | |