The branch stable/12 has been updated by mjg:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2f6dd4a29198ab82ab013e15b4eb2fa6de25d5bf

commit 2f6dd4a29198ab82ab013e15b4eb2fa6de25d5bf
Author:     Mateusz Guzik <[email protected]>
AuthorDate: 2021-07-05 12:45:32 +0000
Commit:     Mateusz Guzik <[email protected]>
CommitDate: 2021-07-05 12:48:23 +0000

    refcount: add refcount_releasen
    
    This is a direct commit as the routine in main was added as a side
    effect of functionality which later got reverted.
---
 sys/sys/refcount.h | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/sys/sys/refcount.h b/sys/sys/refcount.h
index 44edbdf953a0..19a8f38772a0 100644
--- a/sys/sys/refcount.h
+++ b/sys/sys/refcount.h
@@ -70,26 +70,33 @@ refcount_acquire_checked(volatile u_int *count)
 }
 
 static __inline bool
-refcount_release(volatile u_int *count)
+refcount_releasen(volatile u_int *count, u_int n)
 {
        u_int old;
 
        atomic_thread_fence_rel();
-       old = atomic_fetchadd_int(count, -1);
+       old = atomic_fetchadd_int(count, -n);
        KASSERT(old > 0, ("refcount %p is zero", count));
-       if (old > 1)
+       if (old > n)
                return (false);
 
        /*
         * Last reference.  Signal the user to call the destructor.
         *
-        * Ensure that the destructor sees all updates.  The fence_rel
-        * at the start of the function synchronized 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);
 }
 
+static __inline bool
+refcount_release(volatile u_int *count)
+{
+
+        return (refcount_releasen(count, 1));
+}
+
 /*
  * This functions returns non-zero if the refcount was
  * incremented. Else zero is returned.
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to