summaryrefslogtreecommitdiff
path: root/lib/ovs-atomic-pthreads.h
diff options
context:
space:
mode:
authorJarno Rajahalme <jrajahalme@nicira.com>2014-07-07 13:18:46 -0700
committerJarno Rajahalme <jrajahalme@nicira.com>2014-07-07 13:18:46 -0700
commit541bfad20a51d6dc3c051368d70d49e13b040fb9 (patch)
treec2340d9e8ef0e822bb452a5b686f335024b2c1a9 /lib/ovs-atomic-pthreads.h
parent33c6a1b9d4584afc0ac89b25edf666000ad938a7 (diff)
downloadopenvswitch-541bfad20a51d6dc3c051368d70d49e13b040fb9.tar.gz
ovs-atomic: Use explicit memory order for ovs_refcount.
Use explicit variants of atomic operations for the ovs_refcount to avoid the overhead of the default memory_order_seq_cst. Adding a reference requires no memory ordering, as the calling thread is already assumed to have protected access to the object being reference counted. Hence, memory_order_relaxed is used for ovs_refcount_ref(). ovs_refcount_read() does not change the reference count, so it can also use memory_order_relaxed. Unreferencing an object needs a release barrier, so that none of the accesses to the protected object are reordered after the atomic decrement operation. Additionally, an explicit acquire barrier is needed before the object is recycled, to keep the subsequent accesses to the object's memory from being reordered before the atomic decrement operation. This patch follows the memory ordering and argumentation discussed here: http://www.chaoticmind.net/~hcb/projects/boost.atomic/doc/atomic/usage_examples.html Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'lib/ovs-atomic-pthreads.h')
0 files changed, 0 insertions, 0 deletions