refcount: update comments about fencing when releasing counts after r357989
Requested by: kib Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23719
This commit is contained in:
parent
db41308a28
commit
d8a84f08e8
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user