[ovs-dev] [PATCH 02/18] lib/ovs-atomic: Clarified comments on ovs_refcount_unref().
Jarno Rajahalme
jrajahalme at nicira.com
Fri Aug 22 20:58:13 UTC 2014
ovs_refcount_unref() needs to syncronize with the other instances of
itself rather than with ovs_refcount_ref().
Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
lib/ovs-atomic.h | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/ovs-atomic.h b/lib/ovs-atomic.h
index 8e83411..9dd4d67 100644
--- a/lib/ovs-atomic.h
+++ b/lib/ovs-atomic.h
@@ -414,7 +414,10 @@ ovs_refcount_ref(struct ovs_refcount *refcount)
* }
*
* Provides a release barrier making the preceding loads and stores to not be
- * reordered after the unref. */
+ * reordered after the unref, and in case of the last reference provides also
+ * an acquire barrier to keep all the following uninitialization from being
+ * reordered before the atomic decrement operation. Together these synchronize
+ * any concurrent unref operations between each other. */
static inline unsigned int
ovs_refcount_unref(struct ovs_refcount *refcount)
{
@@ -425,8 +428,7 @@ ovs_refcount_unref(struct ovs_refcount *refcount)
ovs_assert(old_refcount > 0);
if (old_refcount == 1) {
/* 'memory_order_release' above means that there are no (reordered)
- * accesses to the protected object from any other thread at this
- * point.
+ * accesses to the protected object from any thread at this point.
* An acquire barrier is needed to keep all subsequent access to the
* object's memory from being reordered before the atomic operation
* above. */
--
1.7.10.4
More information about the dev
mailing list