[PATCH 00/22] Cleanup internal atomic definitions
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Sep 11 17:09:50 GMT 2025
On 11/09/25 12:51, Wilco Dijkstra wrote:
> Hi Uros,
>
>> A patch, following removals of unused target atomic macros could
>> remove #undefs from <include/atomic.h>:
>>
>> # undef atomic_compare_and_exchange_val_acq
>> # undef atomic_compare_and_exchange_val_rel
>> # undef atomic_compare_and_exchange_bool_acq
>
> Yes, also the #undefs for atomic_*_barrier should be removable now.
>
>> Also, I wonder what is the purpose of:
>>
>> # define atomic_forced_read(x) \
>> ({ __typeof (x) __x; __asm ("" : "=r" (__x) : "0" (x)); __x; })
>>
>> This is *not* a scheduling barrier to prevent the compiler from
>> reordering memory accesses (let alone the CPU), because it lacks
>> "memory" clobber and/or volatile qualifier. To guarantee read to a
>> register, this asm should use "memory" clobber, or it should be
>> redefined to use atomic_load_acquire().
>
> It's often redundant, mostly a relaxed load and a few cases load acquire
> in combination with badly written barriers (dl-lookup.c). It's literally
> unbelievable how such broken code still works most of the time...
>
> See https://sourceware.org/pipermail/libc-alpha/2022-July/140844.html
I missed this patch as well, can you send this after this patchset land?
I think we this we can eventually remove atomic_read_barrier.
More information about the Libc-alpha
mailing list