[PATCH v2 3/6] x86: Remove wrong THREAD_ATOMIC_* macros
Siddhesh Poyarekar
siddhesh@gotplt.org
Sat Dec 29 02:13:00 GMT 2018
On 28/12/18 6:32 AM, Adhemerval Zanella wrote:
> The x86 defines optimized THREAD_ATOMIC_* macros where reference always
> the current thread instead of the one indicated by input 'descr' argument.
> It work as long the input is the self thread pointer, however it generates
> wrong code is the semantic is to set a bit atomicialy from another thread.
*if* the semantic is...
>
> This is not an issue for current GLIBC usage, however the new cancellation
> code expects that some synchronization code to atomically set bits from
> different threads.
>
> The generic code generates an additional load to reference to TLS segment,
> for instance the code:
>
> THREAD_ATOMIC_BIT_SET (THREAD_SELF, cancelhandling, CANCELED_BIT);
>
> Compiles to:
>
> lock;orl $4, %fs:776
>
> Where with patch changes it now compiles to:
>
> mov %fs:16,%rax
> lock;orl $4, 776(%rax)
>
> If some usage indeed proves to be a hotspot we can add an extra macro
> with a more descriptive name (THREAD_ATOMIC_BIT_SET_SELF for instance)
> where x86_64 might optimize it.
>
> Checked on x86_64-linux-gnu.
>
> * sysdeps/x86_64/nptl/tls.h (THREAD_ATOMIC_CMPXCHG_VAL,
> THREAD_ATOMIC_AND, THREAD_ATOMIC_BIT_SET): Remove macros.
OK with that nit.
Siddhesh
More information about the Libc-alpha
mailing list