From 6b9247338aa28647942f8a50b119771cef529f43 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Thu, 31 Mar 2022 01:47:19 +0000 Subject: [PATCH 18/49] sys: Use membar_release/acquire around reference drop. This just goes through my recent reference count membar audit and changes membar_exit to membar_release and membar_enter to membar_acquire -- this should make everything cheaper on most CPUs without hurting correctness, because membar_acquire is generally cheaper than membar_enter. --- sys/arch/aarch64/aarch64/pmap.c | 4 ++-- sys/arch/alpha/alpha/pmap.c | 4 ++-- sys/arch/arm/arm32/pmap.c | 4 ++-- sys/arch/hppa/hppa/pmap.c | 4 ++-- sys/arch/ia64/ia64/pmap.c | 6 +++--- sys/arch/powerpc/oea/pmap.c | 4 ++-- sys/arch/sparc/sparc/pmap.c | 4 ++-- sys/arch/sparc64/sparc64/pmap.c | 4 ++-- sys/dev/hyperv/vmbus.c | 4 ++-- sys/dev/marvell/mvxpsec.c | 4 ++-- sys/dev/scsipi/atapiconf.c | 4 ++-- sys/dev/scsipi/scsiconf.c | 4 ++-- sys/dev/scsipi/scsipi_base.c | 4 ++-- sys/external/bsd/drm2/linux/linux_stop_machine.c | 4 ++-- sys/kern/kern_auth.c | 4 ++-- sys/kern/kern_exec.c | 4 ++-- sys/kern/kern_mutex_obj.c | 4 ++-- sys/kern/kern_resource.c | 4 ++-- sys/kern/kern_rwlock_obj.c | 4 ++-- sys/kern/kern_sig.c | 4 ++-- sys/kern/subr_kcpuset.c | 4 ++-- sys/kern/sys_futex.c | 4 ++-- sys/kern/uipc_mbuf.c | 4 ++-- sys/kern/vfs_cwd.c | 4 ++-- sys/kern/vfs_mount.c | 4 ++-- sys/kern/vfs_vnode.c | 14 +++++++------- sys/kern/vfs_wapbl.c | 4 ++-- sys/net/if.c | 4 ++-- sys/net/npf/npf_nat.c | 4 ++-- sys/net/npf/npf_rproc.c | 4 ++-- sys/net/npf/npf_tableset.c | 4 ++-- sys/uvm/pmap/pmap.c | 4 ++-- sys/uvm/uvm_aobj.c | 4 ++-- sys/uvm/uvm_map.c | 4 ++-- 34 files changed, 74 insertions(+), 74 deletions(-) diff --git a/sys/arch/aarch64/aarch64/pmap.c b/sys/arch/aarch64/aarch64/pmap.c index 2815303953cd..9f5a3cdf9210 100644 --- a/sys/arch/aarch64/aarch64/pmap.c +++ b/sys/arch/aarch64/aarch64/pmap.c @@ -1563,11 +1563,11 @@ pmap_destroy(struct pmap *pm) if (pm == pmap_kernel()) panic("cannot destroy kernel pmap"); - membar_exit(); + membar_release(); refcnt = atomic_dec_uint_nv(&pm->pm_refcnt); if (refcnt > 0) return; - membar_enter(); + membar_acquire(); KASSERT(LIST_EMPTY(&pm->pm_pvlist)); pmap_tlb_asid_release_all(pm); diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c index f56a83053607..4e7eac1859cf 100644 --- a/sys/arch/alpha/alpha/pmap.c +++ b/sys/arch/alpha/alpha/pmap.c @@ -1659,11 +1659,11 @@ pmap_destroy(pmap_t pmap) printf("pmap_destroy(%p)\n", pmap); #endif - PMAP_MP(membar_exit()); + PMAP_MP(membar_release()); KASSERT(atomic_load_relaxed(&pmap->pm_count) > 0); if (atomic_dec_uint_nv(&pmap->pm_count) > 0) return; - PMAP_MP(membar_enter()); + PMAP_MP(membar_acquire()); pt_entry_t *lev1map = pmap_lev1map(pmap); diff --git a/sys/arch/arm/arm32/pmap.c b/sys/arch/arm/arm32/pmap.c index 1622a5ffe0ba..510293c37eec 100644 --- a/sys/arch/arm/arm32/pmap.c +++ b/sys/arch/arm/arm32/pmap.c @@ -5275,7 +5275,7 @@ pmap_destroy(pmap_t pm) /* * Drop reference count */ - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&pm->pm_refs) > 0) { #ifndef ARM_MMU_EXTENDED if (pmap_is_current(pm)) { @@ -5286,7 +5286,7 @@ pmap_destroy(pmap_t pm) #endif return; } - membar_enter(); + membar_acquire(); /* * reference count is zero, free pmap resources and then free pmap. diff --git a/sys/arch/hppa/hppa/pmap.c b/sys/arch/hppa/hppa/pmap.c index 6f70350f9653..fbf1a5536990 100644 --- a/sys/arch/hppa/hppa/pmap.c +++ b/sys/arch/hppa/hppa/pmap.c @@ -1249,10 +1249,10 @@ pmap_destroy(pmap_t pmap) off_t off; #endif - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&pmap->pm_obj.uo_refs) > 0) return; - membar_enter(); + membar_acquire(); #ifdef DIAGNOSTIC uvm_page_array_init(&a, &pmap->pm_obj, 0); diff --git a/sys/arch/ia64/ia64/pmap.c b/sys/arch/ia64/ia64/pmap.c index 145dbca4362e..09722466364c 100644 --- a/sys/arch/ia64/ia64/pmap.c +++ b/sys/arch/ia64/ia64/pmap.c @@ -1516,11 +1516,11 @@ pmap_destroy(pmap_t pmap) UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist); UVMHIST_LOG(maphist, "(pm=%p)", pmap, 0, 0, 0); - - membar_exit(); + + membar_release(); if (atomic_dec_64_nv(&pmap->pm_refcount) > 0) return; - membar_enter(); + membar_acquire(); KASSERT(pmap->pm_stats.resident_count == 0); KASSERT(pmap->pm_stats.wired_count == 0); diff --git a/sys/arch/powerpc/oea/pmap.c b/sys/arch/powerpc/oea/pmap.c index 3de683b61731..44e4faa59d77 100644 --- a/sys/arch/powerpc/oea/pmap.c +++ b/sys/arch/powerpc/oea/pmap.c @@ -1230,9 +1230,9 @@ pmap_reference(pmap_t pm) void pmap_destroy(pmap_t pm) { - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&pm->pm_refs) == 0) { - membar_enter(); + membar_acquire(); pmap_release(pm); pool_put(&pmap_pool, pm); } diff --git a/sys/arch/sparc/sparc/pmap.c b/sys/arch/sparc/sparc/pmap.c index 0619ca46f64d..e5a27c6ce849 100644 --- a/sys/arch/sparc/sparc/pmap.c +++ b/sys/arch/sparc/sparc/pmap.c @@ -4465,9 +4465,9 @@ pmap_destroy(struct pmap *pm) { DPRINTF(PDB_DESTROY, "pmap_destroy[%d](%p)", cpu_number(), pm); - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&pm->pm_refcount) == 0) { - membar_enter(); + membar_acquire(); pmap_quiet_check(pm); pool_cache_put(&pmap_cache, pm); } diff --git a/sys/arch/sparc64/sparc64/pmap.c b/sys/arch/sparc64/sparc64/pmap.c index b684114d236e..4a47886f10a7 100644 --- a/sys/arch/sparc64/sparc64/pmap.c +++ b/sys/arch/sparc64/sparc64/pmap.c @@ -1510,11 +1510,11 @@ pmap_destroy(struct pmap *pm) #endif struct vm_page *pg; - membar_exit(); + membar_release(); if ((int)atomic_dec_uint_nv(&pm->pm_refs) > 0) { return; } - membar_enter(); + membar_acquire(); DPRINTF(PDB_DESTROY, ("pmap_destroy: freeing pmap %p\n", pm)); #ifdef MULTIPROCESSOR CPUSET_CLEAR(pmap_cpus_active); diff --git a/sys/dev/hyperv/vmbus.c b/sys/dev/hyperv/vmbus.c index 4e47e8dd73b7..606a6a4dfa0c 100644 --- a/sys/dev/hyperv/vmbus.c +++ b/sys/dev/hyperv/vmbus.c @@ -1452,10 +1452,10 @@ vmbus_channel_detach(struct vmbus_channel *ch) KASSERTMSG(ch->ch_refs > 0, "channel%u: invalid refcnt %d", ch->ch_id, ch->ch_refs); - membar_exit(); + membar_release(); refs = atomic_dec_uint_nv(&ch->ch_refs); if (refs == 0) { - membar_enter(); + membar_acquire(); /* Detach the target channel. */ vmbus_devq_enqueue(ch->ch_sc, VMBUS_DEV_TYPE_DETACH, ch); } diff --git a/sys/dev/marvell/mvxpsec.c b/sys/dev/marvell/mvxpsec.c index c1459c67d578..4ca7d33b0cb6 100644 --- a/sys/dev/marvell/mvxpsec.c +++ b/sys/dev/marvell/mvxpsec.c @@ -1551,10 +1551,10 @@ mvxpsec_session_unref(struct mvxpsec_session *mv_s) { uint32_t refs; - membar_exit(); + membar_release(); refs = atomic_dec_32_nv(&mv_s->refs); if (refs == 0) { - membar_enter(); + membar_acquire(); pool_cache_put(mv_s->sc->sc_session_pool, mv_s); } } diff --git a/sys/dev/scsipi/atapiconf.c b/sys/dev/scsipi/atapiconf.c index c51bcb24d01e..2a40abb958ae 100644 --- a/sys/dev/scsipi/atapiconf.c +++ b/sys/dev/scsipi/atapiconf.c @@ -219,9 +219,9 @@ atapibusdetach(device_t self, int flags) cv_destroy(&chan->chan_cv_comp); cv_destroy(&chan->chan_cv_thr); - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&chan_running(chan)) == 0) { - membar_enter(); + membar_acquire(); mutex_destroy(chan_mtx(chan)); } diff --git a/sys/dev/scsipi/scsiconf.c b/sys/dev/scsipi/scsiconf.c index 88349c54a3e4..bc44eedc3a12 100644 --- a/sys/dev/scsipi/scsiconf.c +++ b/sys/dev/scsipi/scsiconf.c @@ -365,9 +365,9 @@ scsibusdetach(device_t self, int flags) cv_destroy(&chan->chan_cv_comp); cv_destroy(&chan->chan_cv_thr); - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&chan_running(chan)) == 0) { - membar_enter(); + membar_acquire(); mutex_destroy(chan_mtx(chan)); } diff --git a/sys/dev/scsipi/scsipi_base.c b/sys/dev/scsipi/scsipi_base.c index 3fc49c9a2caa..a889eb22c109 100644 --- a/sys/dev/scsipi/scsipi_base.c +++ b/sys/dev/scsipi/scsipi_base.c @@ -2733,10 +2733,10 @@ void scsipi_adapter_delref(struct scsipi_adapter *adapt) { - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&adapt->adapt_refcnt) == 0 && adapt->adapt_enable != NULL) { - membar_enter(); + membar_acquire(); scsipi_adapter_lock(adapt); (void) scsipi_adapter_enable(adapt, 0); scsipi_adapter_unlock(adapt); diff --git a/sys/external/bsd/drm2/linux/linux_stop_machine.c b/sys/external/bsd/drm2/linux/linux_stop_machine.c index 7d22bb63ac28..530bfcb82208 100644 --- a/sys/external/bsd/drm2/linux/linux_stop_machine.c +++ b/sys/external/bsd/drm2/linux/linux_stop_machine.c @@ -59,13 +59,13 @@ stop_machine_xcall(void *a, void *b) s = splhigh(); /* Note that we're ready, and see whether we're the chosen one. */ - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&S->ncpu) != 0) { while (!atomic_load_acquire(&S->done)) SPINLOCK_BACKOFF_HOOK; goto out; } - membar_enter(); + membar_acquire(); /* It's time. Call the callback. */ S->callback(S->cookie); diff --git a/sys/kern/kern_auth.c b/sys/kern/kern_auth.c index 6e7a51152ac2..4679f0dfcd3b 100644 --- a/sys/kern/kern_auth.c +++ b/sys/kern/kern_auth.c @@ -145,12 +145,12 @@ kauth_cred_free(kauth_cred_t cred) ASSERT_SLEEPABLE(); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (atomic_dec_uint_nv(&cred->cr_refcnt) > 0) return; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif kauth_cred_hook(cred, KAUTH_CRED_FREE, NULL, NULL); diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 8325d3fa4d68..5fcc9bc89a7d 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -2138,10 +2138,10 @@ static void spawn_exec_data_release(struct spawn_exec_data *data) { - membar_exit(); + membar_release(); if (atomic_dec_32_nv(&data->sed_refcnt) != 0) return; - membar_enter(); + membar_acquire(); cv_destroy(&data->sed_cv_child_ready); mutex_destroy(&data->sed_mtx_child); diff --git a/sys/kern/kern_mutex_obj.c b/sys/kern/kern_mutex_obj.c index 92fcde00e450..5339b3a42e20 100644 --- a/sys/kern/kern_mutex_obj.c +++ b/sys/kern/kern_mutex_obj.c @@ -158,13 +158,13 @@ mutex_obj_free(kmutex_t *lock) __func__, mo, mo->mo_refcnt); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (atomic_dec_uint_nv(&mo->mo_refcnt) > 0) { return false; } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif mutex_destroy(&mo->mo_lock); pool_cache_put(mutex_obj_cache, mo); diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index fae9c5ac2e35..47d75988eb78 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -793,11 +793,11 @@ lim_free(struct plimit *lim) struct plimit *sv_lim; do { - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&lim->pl_refcnt) > 0) { return; } - membar_enter(); + membar_acquire(); if (lim->pl_corename != defcorename) { kmem_free(lim->pl_corename, lim->pl_cnlen); } diff --git a/sys/kern/kern_rwlock_obj.c b/sys/kern/kern_rwlock_obj.c index 52fa08784d12..f76b75294683 100644 --- a/sys/kern/kern_rwlock_obj.c +++ b/sys/kern/kern_rwlock_obj.c @@ -148,13 +148,13 @@ rw_obj_free(krwlock_t *lock) KASSERT(ro->ro_refcnt > 0); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (atomic_dec_uint_nv(&ro->ro_refcnt) > 0) { return false; } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif rw_destroy(&ro->ro_lock); pool_cache_put(rw_obj_cache, ro); diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 1526f28c94cf..3e5d48cbb4d9 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -311,9 +311,9 @@ void sigactsfree(struct sigacts *ps) { - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&ps->sa_refcnt) == 0) { - membar_enter(); + membar_acquire(); mutex_destroy(&ps->sa_mutex); pool_cache_put(sigacts_cache, ps); } diff --git a/sys/kern/subr_kcpuset.c b/sys/kern/subr_kcpuset.c index 63547abb3e53..506b2a3fd5d5 100644 --- a/sys/kern/subr_kcpuset.c +++ b/sys/kern/subr_kcpuset.c @@ -262,11 +262,11 @@ kcpuset_unuse(kcpuset_t *kcp, kcpuset_t **lst) KASSERT(kc_initialised); KASSERT(kc->kc_refcnt > 0); - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&kc->kc_refcnt) != 0) { return; } - membar_enter(); + membar_acquire(); KASSERT(kc->kc_next == NULL); if (lst == NULL) { kcpuset_destroy(kcp); diff --git a/sys/kern/sys_futex.c b/sys/kern/sys_futex.c index debd9ba33bfc..00f352a13bda 100644 --- a/sys/kern/sys_futex.c +++ b/sys/kern/sys_futex.c @@ -538,7 +538,7 @@ futex_rele(struct futex *f) if (refcnt == 1) goto trylast; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif } while (atomic_cas_ulong(&f->fx_refcnt, refcnt, refcnt - 1) != refcnt); return; @@ -547,7 +547,7 @@ trylast: mutex_enter(&futex_tab.lock); if (atomic_dec_ulong_nv(&f->fx_refcnt) == 0) { #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif if (f->fx_on_tree) { if (__predict_false(f->fx_shared)) diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 49ea7b7c2f7c..6018838772a0 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1915,7 +1915,7 @@ m_ext_free(struct mbuf *m) refcnt = m->m_ext.ext_refcnt = 0; } else { #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif refcnt = atomic_dec_uint_nv(&m->m_ext.ext_refcnt); } @@ -1934,7 +1934,7 @@ m_ext_free(struct mbuf *m) * dropping the last reference */ #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif if (!embedded) { m->m_ext.ext_refcnt++; /* XXX */ diff --git a/sys/kern/vfs_cwd.c b/sys/kern/vfs_cwd.c index 446315157022..7aea7ed8aa19 100644 --- a/sys/kern/vfs_cwd.c +++ b/sys/kern/vfs_cwd.c @@ -138,10 +138,10 @@ void cwdfree(struct cwdinfo *cwdi) { - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&cwdi->cwdi_refcnt) > 0) return; - membar_enter(); + membar_acquire(); vrele(cwdi->cwdi_cdir); if (cwdi->cwdi_rdir) diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c index 8ab0165fb50a..b2e8b9d3d585 100644 --- a/sys/kern/vfs_mount.c +++ b/sys/kern/vfs_mount.c @@ -284,13 +284,13 @@ vfs_rele(struct mount *mp) { #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (__predict_true((int)atomic_dec_uint_nv(&mp->mnt_refcnt) > 0)) { return; } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif /* diff --git a/sys/kern/vfs_vnode.c b/sys/kern/vfs_vnode.c index dc6c3336e2dc..06f24a8bce79 100644 --- a/sys/kern/vfs_vnode.c +++ b/sys/kern/vfs_vnode.c @@ -355,7 +355,7 @@ vstate_assert_change(vnode_t *vp, enum vnode_state from, enum vnode_state to, /* Open/close the gate for vcache_tryvget(). */ if (to == VS_LOADED) { #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif atomic_or_uint(&vp->v_usecount, VUSECOUNT_GATE); } else { @@ -398,10 +398,10 @@ vstate_change(vnode_t *vp, enum vnode_state from, enum vnode_state to) { vnode_impl_t *vip = VNODE_TO_VIMPL(vp); - /* Open/close the gate for vcache_tryvget(). */ + /* Open/close the gate for vcache_tryvget(). */ if (to == VS_LOADED) { #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif atomic_or_uint(&vp->v_usecount, VUSECOUNT_GATE); } else { @@ -736,7 +736,7 @@ vtryrele(vnode_t *vp) u_int use, next; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif for (use = atomic_load_relaxed(&vp->v_usecount);; use = next) { if (__predict_false((use & VUSECOUNT_MASK) == 1)) { @@ -836,7 +836,7 @@ retry: } } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif if (vrefcnt(vp) <= 0 || vp->v_writecount != 0) { vnpanic(vp, "%s: bad ref count", __func__); @@ -1003,7 +1003,7 @@ out: } } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif if (VSTATE_GET(vp) == VS_RECLAIMED && vp->v_holdcnt == 0) { @@ -1476,7 +1476,7 @@ vcache_tryvget(vnode_t *vp) use, (use + 1) | VUSECOUNT_VGET); if (__predict_true(next == use)) { #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif return 0; } diff --git a/sys/kern/vfs_wapbl.c b/sys/kern/vfs_wapbl.c index f5e8f5ca29a5..974c3a9e6595 100644 --- a/sys/kern/vfs_wapbl.c +++ b/sys/kern/vfs_wapbl.c @@ -2273,9 +2273,9 @@ wapbl_inodetrk_free(struct wapbl *wl) /* XXX this KASSERT needs locking/mutex analysis */ KASSERT(wl->wl_inohashcnt == 0); hashdone(wl->wl_inohash, HASH_LIST, wl->wl_inohashmask); - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&wapbl_ino_pool_refcount) == 0) { - membar_enter(); + membar_acquire(); pool_destroy(&wapbl_ino_pool); } } diff --git a/sys/net/if.c b/sys/net/if.c index f2965841919a..72569f3c9658 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1820,12 +1820,12 @@ ifafree(struct ifaddr *ifa) KASSERTMSG(ifa->ifa_refcnt > 0, "ifa_refcnt=%d", ifa->ifa_refcnt); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (atomic_dec_uint_nv(&ifa->ifa_refcnt) != 0) return; #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif free(ifa, M_IFADDR); } diff --git a/sys/net/npf/npf_nat.c b/sys/net/npf/npf_nat.c index d6711165dcf2..bce297033904 100644 --- a/sys/net/npf/npf_nat.c +++ b/sys/net/npf/npf_nat.c @@ -280,13 +280,13 @@ npf_natpolicy_release(npf_natpolicy_t *np) KASSERT(atomic_load_relaxed(&np->n_refcnt) > 0); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (atomic_dec_uint_nv(&np->n_refcnt) != 0) { return; } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif KASSERT(LIST_EMPTY(&np->n_nat_list)); mutex_destroy(&np->n_lock); diff --git a/sys/net/npf/npf_rproc.c b/sys/net/npf/npf_rproc.c index ddf2a622f8d6..65221225fa91 100644 --- a/sys/net/npf/npf_rproc.c +++ b/sys/net/npf/npf_rproc.c @@ -331,13 +331,13 @@ npf_rproc_release(npf_rproc_t *rp) KASSERT(atomic_load_relaxed(&rp->rp_refcnt) > 0); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (atomic_dec_uint_nv(&rp->rp_refcnt) != 0) { return; } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif /* XXXintr */ for (unsigned i = 0; i < rp->rp_ext_count; i++) { diff --git a/sys/net/npf/npf_tableset.c b/sys/net/npf/npf_tableset.c index 2a6ac9f5db9a..12b997559ec1 100644 --- a/sys/net/npf/npf_tableset.c +++ b/sys/net/npf/npf_tableset.c @@ -160,10 +160,10 @@ npf_tableset_destroy(npf_tableset_t *ts) if (t == NULL) continue; - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&t->t_refcnt) > 0) continue; - membar_enter(); + membar_acquire(); npf_table_destroy(t); } kmem_free(ts, NPF_TABLESET_SIZE(ts->ts_nitems)); diff --git a/sys/uvm/pmap/pmap.c b/sys/uvm/pmap/pmap.c index 19847997a03c..5983b2dea21b 100644 --- a/sys/uvm/pmap/pmap.c +++ b/sys/uvm/pmap/pmap.c @@ -690,13 +690,13 @@ pmap_destroy(pmap_t pmap) UVMHIST_FUNC(__func__); UVMHIST_CALLARGS(pmaphist, "(pmap=%#jx)", (uintptr_t)pmap, 0, 0, 0); - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&pmap->pm_count) > 0) { PMAP_COUNT(dereference); UVMHIST_LOG(pmaphist, " <-- done (deref)", 0, 0, 0, 0); return; } - membar_enter(); + membar_acquire(); PMAP_COUNT(destroy); KASSERT(pmap->pm_count == 0); diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c index 6841b2761684..6829a026aa43 100644 --- a/sys/uvm/uvm_aobj.c +++ b/sys/uvm/uvm_aobj.c @@ -605,14 +605,14 @@ uao_detach(struct uvm_object *uobj) UVMHIST_LOG(maphist," (uobj=%#jx) ref=%jd", (uintptr_t)uobj, uobj->uo_refs, 0, 0); #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_exit(); + membar_release(); #endif if (atomic_dec_uint_nv(&uobj->uo_refs) > 0) { UVMHIST_LOG(maphist, "<- done (rc>0)", 0,0,0,0); return; } #ifndef __HAVE_ATOMIC_AS_MEMBAR - membar_enter(); + membar_acquire(); #endif /* diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 15d7ef8d7e30..3c76e8a99fe6 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -4235,10 +4235,10 @@ uvmspace_free(struct vmspace *vm) UVMHIST_CALLARGS(maphist,"(vm=%#jx) ref=%jd", (uintptr_t)vm, vm->vm_refcnt, 0, 0); - membar_exit(); + membar_release(); if (atomic_dec_uint_nv(&vm->vm_refcnt) > 0) return; - membar_enter(); + membar_acquire(); /* * at this point, there should be no other references to the map.