This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] x86_64: Use __seg_tls for thread access when available
- From: Florian Weimer <fweimer at redhat dot com>
- To: Richard Henderson <rth at twiddle dot net>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 8 Oct 2015 11:22:30 +0200
- Subject: Re: [PATCH 2/2] x86_64: Use __seg_tls for thread access when available
- Authentication-results: sourceware.org; auth=none
- References: <1444276705-6797-1-git-send-email-rth at twiddle dot net> <1444276705-6797-3-git-send-email-rth at twiddle dot net>
On 10/08/2015 05:58 AM, Richard Henderson wrote:
> The change in ARCH_FORK is to force conversion to generic address
> space before casting to an integral type; otherwise what we get is
> the unhelpful %fs-based address of tid.
>
> The change in THREAD_ATOMIC_CMPXCHG_VAL is to avoid __typeof copying
> the address space from descr, leading to an error: automatic variable
> with non-default address space.
__SEG_TLS comes from the GCC patches. It needs to be documented
somewhere, see my response on gcc-patches.
> sysdeps/unix/sysv/linux/x86_64/arch-fork.h | 2 +-
> sysdeps/x86_64/nptl/tls.h | 44 ++++++++++++++++++++++--------
> 2 files changed, 34 insertions(+), 12 deletions(-)
Changelog is missing.
> /* Install new dtv for current thread. */
> # define INSTALL_NEW_DTV(dtvp) \
> - ({ struct pthread *__pd; \
> + ({ pthread_self_t *__pd = THREAD_SELF; \
> THREAD_SETMEM (__pd, header.dtv, (dtvp)); })
Does this change code in the !__SEG_TLS case? (THREAD_SETMEM does not
evaluate the __pd argument, which is why this worked before.)
> /* Atomic compare and exchange on TLS, returning old value. */
> # define THREAD_ATOMIC_CMPXCHG_VAL(descr, member, newval, oldval) \
> - ({ __typeof (descr->member) __ret; \
> + ({ __typeof (((struct pthread *)0)->member) __ret; \
> __typeof (oldval) __old = (oldval); \
> if (sizeof (descr->member) == 4) \
> asm volatile (LOCK_PREFIX "cmpxchgl %2, %%fs:%P3" \
The sizeofs should probably refer to __ret instead of descr->member for
consistency.
Florian