Page MenuHomeFreeBSD

libc: Use the initial-exec TLS model for libc on amd64 and arm64
ClosedPublic

Authored by markj on Jul 5 2021, 8:40 PM.
Tags
None
Referenced Files
F87467732: D31070.id92262.diff
Wed, Jul 3, 1:05 PM
Unknown Object (File)
Mon, Jul 1, 2:57 AM
Unknown Object (File)
Sun, Jun 30, 12:25 PM
Unknown Object (File)
Thu, Jun 27, 12:29 PM
Unknown Object (File)
May 28 2024, 10:16 AM
Unknown Object (File)
May 15 2024, 8:57 AM
Unknown Object (File)
May 8 2024, 6:37 AM
Unknown Object (File)
May 7 2024, 4:37 PM
Subscribers

Details

Summary

This permits more efficient accesses of thread-local variables, which
are heavily used at least by jemalloc and locale-aware code. Note that
on amd64, jemalloc's thread-local variables already have their TLS model
overridden by defining JEMALLOC_TLS_MODEL.

PR: 255840
Suggested by: jrtc27

Test Plan

A test program which malloc()s a 64 byte buffer and frees it, in a loop,
completes about 25% faster than before on a EC2 Graviton instance. On
the same system I see no significant difference in buildkernel times.

On an amd64 NUC, a sort -n of some test data was roughly 10% faster with
this change. On the Graviton it was roughly 5% faster.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Jul 5 2021, 8:40 PM
markj added reviewers: kib, jrtc27.
lib/libc/Makefile
57

Why only these architectures? All of them can benefit from this change.

lib/libc/Makefile
57

Mostly for lack of testing. I can try powerpc, i386 and riscv but can't easily test 32-bit arm or mips. In the meantime, it seemed reasonable to enable it first on "tier 1" platforms.

In particular, I had to make a change to rtld to avoid breaking systems with this change on arm64: D31069.

So this assumes that libc is never dlopened, which is practically true but not neccessary hold.

This revision is now accepted and ready to land.Jul 6 2021, 10:57 AM

Enable -ftls-model=initial-exec on i386 and riscv.
Add a comment.

This revision now requires review to proceed.Jul 15 2021, 8:55 PM
kib added inline comments.
lib/libc/Makefile
57

s/safely/reasonably/

59

should aarch64 come first, alphabetically?

This revision is now accepted and ready to land.Jul 15 2021, 10:12 PM
This revision now requires review to proceed.Jul 16 2021, 2:09 AM
This revision was not accepted when it landed; it landed in state Needs Review.Jul 16 2021, 2:42 AM
This revision was automatically updated to reflect the committed changes.