Re: [lttng-dev] [PATCH v2 04/12] urcu/system: Use atomic builtins if configured

"Paul E. McKenney via lttng-dev" <[email protected]>
Newsgroups org.lttng.lists.lttng-dev
Message-ID <81bdddb0-0a8e-4ce7-a40d-789bba0a74e2@paulmck-laptop>
On Wed, Jun 07, 2023 at 02:53:51PM -0400, Olivier Dion wrote:
> If configured to use atomic builtins, use them for implementing the
> CMM_LOAD_SHARED and CMM_STORE_SHARED macros.
> 
> Change-Id: I3eaaaaf0d26c47aced6e94b40fd59c7b8baa6272
> Co-authored-by: Mathieu Desnoyers <[email protected]>
> Signed-off-by: Olivier Dion <[email protected]>
> ---
>  include/urcu/system.h | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/include/urcu/system.h b/include/urcu/system.h
> index faae390..f184aad 100644
> --- a/include/urcu/system.h
> +++ b/include/urcu/system.h
> @@ -19,9 +19,28 @@
>   * all copies or substantial portions of the Software.
>   */
>  
> +#include <urcu/config.h>
>  #include <urcu/compiler.h>
>  #include <urcu/arch.h>
>  
> +#ifdef CONFIG_RCU_USE_ATOMIC_BUILTINS
> +
> +#define CMM_LOAD_SHARED(x)			\
> +	__atomic_load_n(&(x), __ATOMIC_RELAXED)
> +
> +#define _CMM_LOAD_SHARED(x) CMM_LOAD_SHARED(x)
> +
> +#define CMM_STORE_SHARED(x, v)					\
> +	__extension__						\
> +	({							\
> +		__typeof__(v) _v = (v);				\
> +		__atomic_store_n(&(x), _v, __ATOMIC_RELAXED);	\
> +		_v;						\
> +	})
> +
> +#define _CMM_STORE_SHARED(x, v) CMM_STORE_SHARED(x, v)

Same question here on loss of volatile semantics.

							Thanx, Paul

> +
> +#else
>  /*
>   * Identify a shared load. A cmm_smp_rmc() or cmm_smp_mc() should come
>   * before the load.
> @@ -56,4 +75,6 @@
>  		_v = _v;	/* Work around clang "unused result" */	\
>  	})
>  
> +#endif	/* CONFIG_RCU_USE_ATOMIC_BUILTINS */
> +
>  #endif /* _URCU_SYSTEM_H */
> -- 
> 2.40.1
> 
_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.