Index: sys/kern/kern_synch.c =================================================================== --- sys/kern/kern_synch.c +++ sys/kern/kern_synch.c @@ -368,8 +368,8 @@ /* * Last reference. Signal the user to call the destructor. * - * Ensure that the destructor sees all updates. The fence_rel - * at the start of refcount_releasen synchronizes with this fence. + * Ensure that the destructor sees all updates. This synchronizes + * with release fences from all routines which drop the count. */ atomic_thread_fence_acq(); return (true); Index: sys/sys/refcount.h =================================================================== --- sys/sys/refcount.h +++ sys/sys/refcount.h @@ -119,6 +119,9 @@ KASSERT(n < REFCOUNT_SATURATION_VALUE / 2, ("refcount_releasen: n=%u too large", n)); + /* + * Paired with acquire fence in refcount_release_last. + */ atomic_thread_fence_rel(); old = atomic_fetchadd_int(count, -n); if (__predict_false(n >= REFCOUNT_COUNT(old) || @@ -198,6 +201,9 @@ return (false); if (__predict_false(REFCOUNT_SATURATED(old))) return (true); + /* + * Paired with acquire fence in refcount_release_last. + */ if (atomic_fcmpset_rel_int(count, &old, old - 1)) return (true); }