[ovs-dev] [PATCH 03/12] lib/ovs-atomic: Add atomic compare_exchange.

Ben Pfaff blp at nicira.com
Thu Jul 3 21:26:46 UTC 2014


On Mon, Jun 30, 2014 at 08:17:19AM -0700, Jarno Rajahalme wrote:
> Add support for atomic compare_exchange operations.
> 
> Add ovs_refcount_try_ref(), which takes a reference only if the
> refcount is non-zero and returns true if a reference was taken, false
> otherwise.  This can be used in combined RCU/refcount scenarios where
> we have an RCU protected reference to an refcounted object, but which
> may be unref'ed at any time.  If ovs_refcount_try_ref() fails, the
> object may still be safely used until the current thread quiesces.
> 
> Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>

I doubt that "relaxed" memory order is good enough here, given the
commentary on the previous patch.

Not every architecture supports compare-and-exchange, but it sounds
like probably the ones we care about do (do we need to support ARMv6
or PA-RISC?).



More information about the dev mailing list