From 32c369f40c3f123140e08d6f60b1ac6603a007e6 Mon Sep 17 00:00:00 2001 From: Justin Hibbits <jhibbits@FreeBSD.org> Date: Wed, 6 Jun 2018 12:57:11 +0000 Subject: [PATCH] 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. --- sys/kern/vfs_subr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 055d3a828bf4..286a871c3631 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -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;