diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 1a19e67bc21..435f1a63a52 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -368,8 +368,8 @@ refcount_release_last(volatile u_int *count, u_int n, u_int old) /* * 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); diff --git a/sys/sys/refcount.h b/sys/sys/refcount.h index 9173793c328..a3becb5558a 100644 --- a/sys/sys/refcount.h +++ b/sys/sys/refcount.h @@ -119,6 +119,9 @@ refcount_releasen(volatile u_int *count, u_int n) 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 @@ refcount_release_if_gt(volatile u_int *count, u_int n) 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); }