From owner-svn-src-all@freebsd.org Wed Jun 6 14:03:29 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 196EAFF73AE; Wed, 6 Jun 2018 14:03:29 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 87A7F75EBC; Wed, 6 Jun 2018 14:03:28 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTP id w56E3COl022871; Wed, 6 Jun 2018 17:03:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w56E3COl022871 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w56E3B7L022870; Wed, 6 Jun 2018 17:03:11 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 6 Jun 2018 17:03:11 +0300 From: Konstantin Belousov To: Justin Hibbits Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r334708 - head/sys/kern Message-ID: <20180606140311.GU2450@kib.kiev.ua> References: <201806061257.w56CvCwq089369@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201806061257.w56CvCwq089369@repo.freebsd.org> User-Agent: Mutt/1.10.0 (2018-05-17) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Jun 2018 14:03:29 -0000 On Wed, Jun 06, 2018 at 12:57:12PM +0000, Justin Hibbits wrote: > Author: jhibbits > Date: Wed Jun 6 12:57:11 2018 > New Revision: 334708 > URL: https://svnweb.freebsd.org/changeset/base/334708 > > Log: > Add a memory barrier after taking a reference on the vnode holdcnt in _vhold > > This is needed to avoid a race between the VNASSERT() below, and another > thread updating the VI_FREE flag, on weakly-ordered architectures. > > On a 72-thread POWER9, without this barrier a 'make -j72 buildworld' would > panic on the assert regularly. > > It may be possible to use a weaker barrier, and I'll investigate that once > all stability issues are worked out on POWER9. > > Modified: > head/sys/kern/vfs_subr.c > > Modified: head/sys/kern/vfs_subr.c > ============================================================================== > --- head/sys/kern/vfs_subr.c Wed Jun 6 10:46:24 2018 (r334707) > +++ head/sys/kern/vfs_subr.c Wed Jun 6 12:57:11 2018 (r334708) > @@ -2807,6 +2807,9 @@ _vhold(struct vnode *vp, bool locked) > CTR2(KTR_VFS, "%s: vp %p", __func__, vp); > if (!locked) { > if (refcount_acquire_if_not_zero(&vp->v_holdcnt)) { > +#if !defined(__amd64__) && !defined(__i386__) > + mb(); > +#endif > VNASSERT((vp->v_iflag & VI_FREE) == 0, vp, > ("_vhold: vnode with holdcnt is free")); > return; First, mb() must not be used in the FreeBSD code at all. Look at atomic_thread_fenceXXX(9) KPI. Second, you need the reciprocal fence between clearing of VI_FREE and refcount_acquire(), otherwise the added barrier is nop. Most likely, you got away with it because there is a mutex unlock between clearing of VI_FREE and acquire, which release semantic you abused. Does the fence needed for the non-invariants case ? Fourth, doesn't v_usecount has the same issues WRT inactivation ?