Author: mjg
Date: Sun Feb 16 18:20:09 2020
New Revision: 358007
URL: https://svnweb.freebsd.org/changeset/base/358007

Log:
  refcount: update comments about fencing when releasing counts after r357989
  
  Requested by: kib
  Reviewed by:  kib
  Differential Revision:        https://reviews.freebsd.org/D23719

Modified:
  head/sys/kern/kern_synch.c
  head/sys/sys/refcount.h

Modified: head/sys/kern/kern_synch.c
==============================================================================
--- head/sys/kern/kern_synch.c  Sun Feb 16 17:55:32 2020        (r358006)
+++ head/sys/kern/kern_synch.c  Sun Feb 16 18:20:09 2020        (r358007)
@@ -368,8 +368,8 @@ refcount_release_last(volatile u_int *count, u_int n, 
        /*
         * 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);

Modified: head/sys/sys/refcount.h
==============================================================================
--- head/sys/sys/refcount.h     Sun Feb 16 17:55:32 2020        (r358006)
+++ head/sys/sys/refcount.h     Sun Feb 16 18:20:09 2020        (r358007)
@@ -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);
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to