Skip to content

Commit

Permalink
lib/ovs-atomic: Clarified comments on ovs_refcount_unref().
Browse files Browse the repository at this point in the history
ovs_refcount_unref() needs to syncronize with the other instances of
itself rather than with ovs_refcount_ref().

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
Jarno Rajahalme committed Aug 29, 2014
1 parent 0b83904 commit 2864e62
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/ovs-atomic.h
Expand Up @@ -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)
{
Expand All @@ -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. */
Expand Down

0 comments on commit 2864e62

Please sign in to comment.