From 5b718d5cf8bd8df82e37825e0cdb6f986d9a784a Mon Sep 17 00:00:00 2001 From: Sirshak Das Date: Fri, 12 Oct 2018 09:38:27 -0500 Subject: Enable atomic swap and store macro with acquire and release ordering Add atomic swap and store macro with acquire and release ordering respectively. Variable in question is interupt_pending variable which is used as guard variable by input nodes to process the device queue. Atomic Swap is used with Acquire ordering as writes or reads following this in program order should not be reordered before the swap. Atomic Store is used with Release ordering, as post store the node is added to pending list. Change-Id: I1be49e91a15c58d0bf21ff5ba1bd37d5d7d12f7a Original-patch-by: Damjan Marion Signed-off-by: Sirshak Das Reviewed-by: Honnappa Nagarahalli Reviewed-by: Ola Liljedahl --- src/vppinfra/atomics.h | 5 +++-- src/vppinfra/smp.h | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/vppinfra') diff --git a/src/vppinfra/atomics.h b/src/vppinfra/atomics.h index 8ddf13801df..420ae837fc0 100644 --- a/src/vppinfra/atomics.h +++ b/src/vppinfra/atomics.h @@ -37,9 +37,10 @@ #define clib_atomic_cmp_and_swap(addr,old,new) __sync_val_compare_and_swap(addr, old, new) #define clib_atomic_bool_cmp_and_swap(addr,old,new) __sync_bool_compare_and_swap(addr, old, new) -/*Accquire Barrier*/ #define clib_atomic_test_and_set(a) __sync_lock_test_and_set(a, 1) -/*Release Barrier*/ #define clib_atomic_release(a) __sync_lock_release(a) +#define clib_atomic_store_rel_n(a, b) __atomic_store_n ((a), (b), __ATOMIC_RELEASE) +#define clib_atomic_swap_acq_n(a, b) __atomic_exchange_n ((a), (b), __ATOMIC_ACQUIRE) + #endif /* included_clib_atomics_h */ diff --git a/src/vppinfra/smp.h b/src/vppinfra/smp.h index 7146e51ac77..2b3ed548dfa 100644 --- a/src/vppinfra/smp.h +++ b/src/vppinfra/smp.h @@ -41,8 +41,6 @@ #include #include /* for os_panic */ -#define clib_smp_swap(addr,new) __sync_lock_test_and_set(addr,new) - #if defined (i386) || defined (__x86_64__) #define clib_smp_pause() do { asm volatile ("pause"); } while (0) #elif defined (__aarch64__) || defined (__arm__) -- cgit 1.2.3-korg