From owner-svn-src-head@freebsd.org Mon Aug 19 04:30:47 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1E98DA80A1; Mon, 19 Aug 2019 04:30:47 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46Bgw61z86z4JNZ; Mon, 19 Aug 2019 04:30:46 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-ot1-x343.google.com with SMTP id c7so481474otp.1; Sun, 18 Aug 2019 21:30:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=dd+XnnQ3liyVhAWMXlup6qCDg2OCvrQbGppgOE2qrO4=; b=WktQsWUrxjMoo4rXxu9Aq4cXNhz4He3lbkOiqkR5aark3iwCSEjqz6soa5CR9FA3bX 5dCEExzc7a/PTQZetiwpqtHHoR9k1PaM1Dr/bPCw+jjmyQn++svZOt0AdBjDQy8VHoqs GnGaxw+ntNDPo+pR2ECcE/DUAdYf48YRPGEcqdjZWrAywVJ+tsQKSs4lw0CUKp3kVQ6A l3T6n7cM6VTXolsxImHU61UWYi962OwDfiSarDRAXKt0Z0Cj0jxfBqlPq1X37ujlsbct 9Vq3lmsg0brAJl8asXnPliKXGHUULkqNCou6BWX9hk0rPUCkNvE40aFoUyFSVA5BQya+ P+eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=dd+XnnQ3liyVhAWMXlup6qCDg2OCvrQbGppgOE2qrO4=; b=Z8bbahcbRWscii9IfgxjcJAiODRoOeAuWNhLtSvIetyVU7OWJtiBNts0Y+glSi2Bxu r4e35eHOTuz+mgmi9grc3ZwU48UNTcMfigbnUHgKIVR4d16Ml3I/3elcukl9i+OlCbop kF47WzKEdNbzZH+Yl/Fodg33qm4PaBN48tv6cm16WhvbVvEqa2A1yJ8DH55Kyuhx0vY8 4/J2cuNuURx9HwByq1UKS9iukbBv4ZVHlXuyx+NVlc7b6J+dMmtmrjOhGHlMM1TLvll1 EkJLEARGJeZZRRKBed1YXFsXGy7UOc1oQkCgshrccJAuqt2MSANOYNM2675rpaNwHajW /3hA== X-Gm-Message-State: APjAAAWDHJDRBOL1Xmcujbw29bTPqeGeBgB14XX+PlZQxxjB6JbzGpmY DRbsrBdHeiaGQP8G7xrpYGuAM+x92xzb64QcQ8k= X-Google-Smtp-Source: APXvYqytoAou/JbnnzCToBbs3VT2zOBcdQ0kjmPDANLQLPbfG//92fdQmZ5I2OcxtiZzKXSr7aN+E6sZBHOxl+hiWFA= X-Received: by 2002:a9d:7f05:: with SMTP id j5mr5379605otq.102.1566189044648; Sun, 18 Aug 2019 21:30:44 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4a:2516:0:0:0:0:0 with HTTP; Sun, 18 Aug 2019 21:30:44 -0700 (PDT) In-Reply-To: <201908190409.x7J49o32014802@slippy.cwsent.com> References: <201908181840.x7IIeCAL055888@repo.freebsd.org> <201908190409.x7J49o32014802@slippy.cwsent.com> From: Mateusz Guzik Date: Mon, 19 Aug 2019 06:30:44 +0200 Message-ID: Subject: Re: svn commit: r351193 - head/sys/kern To: Cy Schubert Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 46Bgw61z86z4JNZ X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=WktQsWUr; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2607:f8b0:4864:20::343 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.98 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(0.00)[ip: (2.94), ipnet: 2607:f8b0::/32(-2.95), asn: 15169(-2.38), country: US(-0.05)]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_DN_SOME(0.00)[]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[3.4.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Aug 2019 04:30:47 -0000 Sorry, cannot test right now. Does this fix it for you? diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 6a1547854c9d..0cde451e5890 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -466,18 +466,12 @@ kern_getfsstat(struct thread *td, struct statfs **buf, size_t bufsize, } if (sfsp != NULL && count < maxcount) { sp = &mp->mnt_stat; - /* - * If MNT_NOWAIT is specified, do not refresh - * the fsstat cache. - */ - if (mode != MNT_NOWAIT) { - error = VFS_STATFS(mp, sp); - if (error != 0) { - mtx_lock(&mountlist_mtx); - nmp = TAILQ_NEXT(mp, mnt_list); - vfs_unbusy(mp); - continue; - } + error = VFS_STATFS(mp, sp); + if (error != 0) { + mtx_lock(&mountlist_mtx); + nmp = TAILQ_NEXT(mp, mnt_list); + vfs_unbusy(mp); + continue; } if (priv_check(td, PRIV_VFS_GENERATION)) { sptmp = malloc(sizeof(struct statfs), M_STATFS, On 8/19/19, Cy Schubert wrote: > In message <201908181840.x7IIeCAL055888@repo.freebsd.org>, Mateusz Guzik > writes > : >> Author: mjg >> Date: Sun Aug 18 18:40:12 2019 >> New Revision: 351193 >> URL: https://svnweb.freebsd.org/changeset/base/351193 >> >> Log: >> vfs: stop always overwriting ->mnt_stat in VFS_STATFS >> >> The struct is already populated on each mount (and remount). Fields are >> eit >> her >> constant or not used by filesystem in the first place. >> >> Some infrequently used functions use it to avoid having to allocate a >> new b >> uffer >> and are left alone. >> >> The current code results in an avoidable copying single-threaded and >> signif >> icant >> cache line bouncing multithreaded >> >> While here deduplicate initial filling of the struct. >> >> Reviewed by: kib >> Sponsored by: The FreeBSD Foundation >> Differential Revision: https://reviews.freebsd.org/D21317 >> >> Modified: >> head/sys/kern/vfs_mount.c >> head/sys/kern/vfs_syscalls.c >> >> Modified: head/sys/kern/vfs_mount.c >> ============================================================================= >> = >> --- head/sys/kern/vfs_mount.c Sun Aug 18 17:12:06 2019 (r351192) >> +++ head/sys/kern/vfs_mount.c Sun Aug 18 18:40:12 2019 (r351193) >> @@ -1831,12 +1831,15 @@ vfs_copyopt(struct vfsoptlist *opts, const char >> *name >> , >> int >> __vfs_statfs(struct mount *mp, struct statfs *sbp) >> { >> - int error; >> >> - error = mp->mnt_op->vfs_statfs(mp, &mp->mnt_stat); >> - if (sbp != &mp->mnt_stat) >> - *sbp = mp->mnt_stat; >> - return (error); >> + /* >> + * Set these in case the underlying filesystem fails to do so. >> + */ >> + sbp->f_version = STATFS_VERSION; >> + sbp->f_namemax = NAME_MAX; >> + sbp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; >> + >> + return (mp->mnt_op->vfs_statfs(mp, sbp)); >> } >> >> void >> >> Modified: head/sys/kern/vfs_syscalls.c >> ============================================================================= >> = >> --- head/sys/kern/vfs_syscalls.c Sun Aug 18 17:12:06 2019 (r35119 >> 2) >> +++ head/sys/kern/vfs_syscalls.c Sun Aug 18 18:40:12 2019 (r35119 >> 3) >> @@ -248,7 +248,6 @@ statfs_scale_blocks(struct statfs *sf, long max_size) >> static int >> kern_do_statfs(struct thread *td, struct mount *mp, struct statfs *buf) >> { >> - struct statfs *sp; >> int error; >> >> if (mp == NULL) >> @@ -262,17 +261,9 @@ kern_do_statfs(struct thread *td, struct mount *mp, >> st >> if (error != 0) >> goto out; >> #endif >> - /* >> - * Set these in case the underlying filesystem fails to do so. >> - */ >> - sp = &mp->mnt_stat; >> - sp->f_version = STATFS_VERSION; >> - sp->f_namemax = NAME_MAX; >> - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; >> - error = VFS_STATFS(mp, sp); >> + error = VFS_STATFS(mp, buf); >> if (error != 0) >> goto out; >> - *buf = *sp; >> if (priv_check(td, PRIV_VFS_GENERATION)) { >> buf->f_fsid.val[0] = buf->f_fsid.val[1] = 0; >> prison_enforce_statfs(td->td_ucred, mp, buf); >> @@ -476,13 +467,6 @@ restart: >> if (sfsp != NULL && count < maxcount) { >> sp = &mp->mnt_stat; >> /* >> - * Set these in case the underlying filesystem >> - * fails to do so. >> - */ >> - sp->f_version = STATFS_VERSION; >> - sp->f_namemax = NAME_MAX; >> - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; >> - /* >> * If MNT_NOWAIT is specified, do not refresh >> * the fsstat cache. >> */ >> @@ -4545,7 +4529,6 @@ sys_fhstatfs(struct thread *td, struct fhstatfs_args >> * >> int >> kern_fhstatfs(struct thread *td, fhandle_t fh, struct statfs *buf) >> { >> - struct statfs *sp; >> struct mount *mp; >> struct vnode *vp; >> int error; >> @@ -4569,16 +4552,7 @@ kern_fhstatfs(struct thread *td, fhandle_t fh, >> struct >> if (error != 0) >> goto out; >> #endif >> - /* >> - * Set these in case the underlying filesystem fails to do so. >> - */ >> - sp = &mp->mnt_stat; >> - sp->f_version = STATFS_VERSION; >> - sp->f_namemax = NAME_MAX; >> - sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; >> - error = VFS_STATFS(mp, sp); >> - if (error == 0) >> - *buf = *sp; >> + error = VFS_STATFS(mp, buf); >> out: >> vfs_unbusy(mp); >> return (error); >> > > Hi mjg@, > > This revsion has caused a df(1) and statfs(2) a bit of gas. > > cwsys# df -h / > Filesystem Size Used Avail Capacity Mounted on > dsk02/src 1.9G 551M 1.2G 30% /opt/src > cwsys# > cwsys# df -h /usr > Filesystem Size Used Avail Capacity Mounted on > dsk02/var/mqueue 2.9G 1.3G 1.4G 47% /var/spool/mqueue > cwsys# df -h /var > Filesystem Size Used Avail Capacity Mounted on > dsk02/src/svn-current 1.9G 1.4G 380M 79% > /opt/src/svn-current > cwsys# df -h /var/tmp > Filesystem Size Used Avail Capacity Mounted on > dsk02/src 992M 198M 714M 22% /opt/src > cwsys# > > cwfw# df -h / > Filesystem Size Used Avail Capacity Mounted on > 4.0G 1.6G 2.0G 45% > cwfw# df -h /usr > Filesystem Size Used Avail Capacity Mounted on > 4.0G 1.6G 2.0G 45% > cwfw# df -h /var > Filesystem Size Used Avail Capacity Mounted on > 2.9G 647M 2.0G 24% > cwfw# df -h /tmp > Filesystem Size Used Avail Capacity Mounted on > 300M 4.0K 300M 0% > cwfw# df -h /var/tmp > Filesystem Size Used Avail Capacity Mounted on > 2.9G 648M 2.0G 24% > cwfw# > > Reverting this revision corrected this regression. > > > -- > Cheers, > Cy Schubert > FreeBSD UNIX: Web: http://www.FreeBSD.org > > The need of the many outweighs the greed of the few. > > > -- Mateusz Guzik