This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 3c449bd75224b543de394bf6444c09cfbc6e104f (commit) via c3c447c96ab63092461dee2bac607f59a21bf8de (commit) from c7bf6a71fe08f3ba8228eced708c9d05496a825a (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 3c449bd75224b543de394bf6444c09cfbc6e104f Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Jun 4 17:03:44 2018 +0300
linux-gen: queue_lf: use lock free 128 bit atomics
Use 128 bit atomics from arch/aarch64 directory. On ARMv8, GCC built-in atomics does not utilize 128 bit atomic instructions but uses locks instead. All other targets use GGC built-ins (when lock free).
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_queue_lf.c b/platform/linux-generic/odp_queue_lf.c index 1c3c6bc4..e4902a3f 100644 --- a/platform/linux-generic/odp_queue_lf.c +++ b/platform/linux-generic/odp_queue_lf.c @@ -24,14 +24,55 @@
typedef unsigned __int128 u128_t;
+static inline void atomic_zero_u128(u128_t *atomic) +{ + __atomic_store_n(atomic, 0, __ATOMIC_RELAXED); +} + +#if defined(__aarch64__) +/* ARMv8 has atomic load-acq/store-rel instructions for a pair of + * 64bit of data. GCC atomic built-in for 128bits does not utilize these + * instructions but uses locks instead. Override GCC built-in for ARMv8. + */ +#include <odp_cpu.h> + +static inline int atomic_cas_rel_u128(u128_t *atomic, u128_t old_val, + u128_t new_val) +{ + return __lockfree_compare_exchange_16((__int128 *)atomic, + (__int128 *)&old_val, + new_val, + 0, + __ATOMIC_RELEASE, + __ATOMIC_RELAXED); +} + +static inline int atomic_cas_acq_u128(u128_t *atomic, u128_t old_val, + u128_t new_val) +{ + return __lockfree_compare_exchange_16((__int128 *)atomic, + (__int128 *)&old_val, + new_val, + 0, + __ATOMIC_ACQUIRE, + __ATOMIC_RELAXED); +} + static inline u128_t atomic_load_u128(u128_t *atomic) { - return __atomic_load_n(atomic, __ATOMIC_RELAXED); + return __lockfree_load_16((__int128 *)atomic, __ATOMIC_RELAXED); }
-static inline void atomic_zero_u128(u128_t *atomic) +static inline int atomic_is_lockfree_u128(void) { - __atomic_store_n(atomic, 0, __ATOMIC_RELAXED); + return 1; +} + +#else + +static inline u128_t atomic_load_u128(u128_t *atomic) +{ + return __atomic_load_n(atomic, __ATOMIC_RELAXED); }
static inline int atomic_cas_rel_u128(u128_t *atomic, u128_t old_val, @@ -57,6 +98,8 @@ static inline int atomic_is_lockfree_u128(void) return __atomic_is_lock_free(16, NULL); }
+#endif + #else
/* These definitions enable build in non 128 bit compatible systems.
commit c3c447c96ab63092461dee2bac607f59a21bf8de Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Jun 4 14:18:12 2018 +0300
linux-gen: queue_lf: wrap is_lock_free function
Wrap GCC built-in __atomic_is_lock_free function so that it can be overridden on ARMv8.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/odp_queue_lf.c b/platform/linux-generic/odp_queue_lf.c index b3cfbdbe..1c3c6bc4 100644 --- a/platform/linux-generic/odp_queue_lf.c +++ b/platform/linux-generic/odp_queue_lf.c @@ -52,6 +52,11 @@ static inline int atomic_cas_acq_u128(u128_t *atomic, u128_t old_val, __ATOMIC_RELAXED); }
+static inline int atomic_is_lockfree_u128(void) +{ + return __atomic_is_lock_free(16, NULL); +} + #else
/* These definitions enable build in non 128 bit compatible systems. @@ -86,6 +91,11 @@ static inline int atomic_cas_acq_u128(u128_t *atomic, u128_t old_val, return atomic_cas_rel_u128(atomic, old_val, new_val); }
+static inline int atomic_is_lockfree_u128(void) +{ + return 0; +} + #endif
/* Node in lock-free ring */ @@ -263,12 +273,10 @@ uint32_t queue_lf_init_global(uint32_t *queue_lf_size, queue_lf_func_t *lf_func) { odp_shm_t shm; - bool lockfree = 0; + int lockfree;
/* 16 byte lockfree CAS operation is needed. */ -#ifdef __SIZEOF_INT128__ - lockfree = __atomic_is_lock_free(16, NULL); -#endif + lockfree = atomic_is_lockfree_u128();
ODP_DBG("\nLock-free queue init\n"); ODP_DBG(" u128 lock-free: %i\n\n", lockfree);
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/odp_queue_lf.c | 65 +++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-)
hooks/post-receive