[lttng-dev] [PATCH 02/11] urcu/uatomic: Use atomic builtins if configured

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Thu Jun 22 15:56:54 EDT 2023


On 6/22/23 15:53, Olivier Dion wrote:
> On Thu, 22 Jun 2023, "Paul E. McKenney" <paulmck at kernel.org> wrote:
> 
>> I suggest C11 volatile atomic load/store.  Load/store fusing is permitted
>> for non-volatile atomic loads and stores, and such fusing can ruin your
>> code's entire day.  ;-)
> 
> Good catch.  Seems like not a problem on GCC (yet), but Clang is extremely
> aggressive and seems to do store fusing on some corner cases [0].

I don't think this is an example of store fusing, but rather just that 
the compiler can eliminate stores to static variables which are 
otherwise unused, making the entire variable useless.

Thanks,

Mathieu

> 
> However, I do not find any simple reproducer of load/store fusing.  Do
> you have example of such fusing, or is this a precaution?  In the
> meantime, back to reading the standard to be certain :-)
> 
>   [0] https://godbolt.org/z/odKG9a75a
> 

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com



More information about the lttng-dev mailing list