This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] x86-64: Align the stack in __tls_get_addr [BZ #21609]


On Thu, 6 Jul 2017, Carlos O'Donell wrote:
> (a) __tls_get_addr aligns the stack for you if required, with a fast and
>     slow path, everyone pays the small cost to check fir misalignment, and
>     only the broken old binaries are forced to realign. This change works
>     for old and new binaries without any need to coordinate between the
>     compiler and the runtime.
> 
>     Pro: No gcc/glibc coordination (no additional flags).
>     Con: All applications pay a small cost to check.

No, this is not entirely accurate.

Only *on first access to a given TLS object in a given thread* you go
via the slow path and need to realign the stack.

In which case the work to realign the stack is _tiny_ compared to the
amount of work Glibc already does on initial TLS access.

Repeated accesses to TLS data can go via the fast path and *not even
check stack alignment*.  There's no additional cost there.

There is no need to introduce new symbols nor symbol versions. It's
sufficient to implement amd64 __tls_get_attr in assembly, rename generic
__tls_get_attr, and call the renamed generic implementation from the slow
path after realigning the stack.

(it's might be even possible to avoid "in assembly" part by relying on
optimization and GCC extensions to achieve the same)

Alexander


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]