glibc/sysdeps/x86_64
Szabolcs Nagy d2123d6827 elf: Fix slow tls access after dlopen [BZ #19924]
In short: __tls_get_addr checks the global generation counter and if
the current dtv is older then _dl_update_slotinfo updates dtv up to the
generation of the accessed module. So if the global generation is newer
than generation of the module then __tls_get_addr keeps hitting the
slow dtv update path. The dtv update path includes a number of checks
to see if any update is needed and this already causes measurable tls
access slow down after dlopen.

It may be possible to detect up-to-date dtv faster.  But if there are
many modules loaded (> TLS_SLOTINFO_SURPLUS) then this requires at
least walking the slotinfo list.

This patch tries to update the dtv to the global generation instead, so
after a dlopen the tls access slow path is only hit once.  The modules
with larger generation than the accessed one were not necessarily
synchronized before, so additional synchronization is needed.

This patch uses acquire/release synchronization when accessing the
generation counter.

Note: in the x86_64 version of dl-tls.c the generation is only loaded
once, since relaxed mo is not faster than acquire mo load.

I have not benchmarked this. Tested by Adhemerval Zanella on aarch64,
powerpc, sparc, x86 who reported that it fixes the performance issue
of bug 19924.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2023-09-01 08:21:37 +01:00
..
64 ld.so: Always use MAP_COPY to map the first segment [BZ #30452] 2023-06-30 10:42:42 -07:00
fpu x86_64: Add log1p with FMA 2023-08-21 10:44:26 -07:00
htl htl: Add tcb-offsets.sym for x86_64 2023-04-03 01:15:30 +02:00
multiarch wchar: Avoid PLT entries with _FORTIFY_SOURCE 2023-07-05 16:59:48 +02:00
nptl nptl: move tst-x86-64-tls-1 to nptl-only tests 2023-05-01 12:59:33 +02:00
sys hurd: Add sys/ucontext.h and sigcontext.h for x86_64 2023-04-10 20:11:43 +02:00
x32 Parameterize op_t from memcopy.h 2023-02-06 16:19:35 -03:00
____longjmp_chk.S
__longjmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
_mcount.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
abort-instr.h
add_n.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
addmul_1.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
bsd-_setjmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
bsd-setjmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
configure configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
configure.ac x86/configure.ac: Define PI_STATIC_AND_HIDDEN/SUPPORT_STATIC_PIE 2022-02-14 07:34:54 -08:00
crti.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
crtn.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-cache.h x86: Make dl-cache.h and readelflib.c not Linux-specific 2023-06-26 10:04:31 -03:00
dl-hwcaps-subdirs.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-irel.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-machine.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-procinfo.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-runtime.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-tls.c elf: Fix slow tls access after dlopen [BZ #19924] 2023-09-01 08:21:37 +01:00
dl-tls.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-tlsdesc.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-tlsdesc.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
dl-trampoline.h Fix misspellings in sysdeps/x86_64 -- BZ 25337. 2023-05-23 10:25:11 +00:00
dl-trampoline.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ffs.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ffsll.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ifuncmain8.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
ifuncmod8.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
Implies Remove dbl-64/wordsize-64 (part 2) 2021-01-07 15:26:26 +00:00
isa-default-impl.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
isa.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
jmpbuf-offsets.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
jmpbuf-unwind.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
l10nflist.c Minor optimization of popcount in l10nflist 2011-08-11 14:07:04 -04:00
link-defines.sym elf: Remove Intel MPX support (lazy PLT, ld.so profile, and LD_AUDIT) 2021-10-11 11:14:02 -07:00
locale-defines.sym
localplt.data elf: Rework exception handling in the dynamic loader [BZ #25486] 2022-11-03 09:39:31 +01:00
lshift.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
machine-gmon.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
Makefile nptl: move tst-x86-64-tls-1 to nptl-only tests 2023-05-01 12:59:33 +02:00
memchr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
memcmp-isa-default-impl.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
memcmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
memcmpeq.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
memcpy_chk.S string: Ensure *_chk routines have their hidden builtin definition available 2023-07-05 16:59:48 +02:00
memcpy.S x86_64: Fix build with --disable-multiarch (BZ 30721) 2023-08-10 10:29:29 -03:00
memmove_chk.S string: Ensure *_chk routines have their hidden builtin definition available 2023-07-05 16:59:48 +02:00
memmove.S x86_64: Fix build with --disable-multiarch (BZ 30721) 2023-08-10 10:29:29 -03:00
mempcpy_chk.S string: Ensure *_chk routines have their hidden builtin definition available 2023-07-05 16:59:48 +02:00
mempcpy.S X86-64: Remove previous default/SSE2/AVX2 memcpy/memmove 2016-06-08 13:58:08 -07:00
memrchr.S string: Add libc_hidden_proto for memrchr 2023-02-08 17:13:58 -03:00
memset_chk.S string: Ensure *_chk routines have their hidden builtin definition available 2023-07-05 16:59:48 +02:00
memset.S x86_64: Fix build with --disable-multiarch (BZ 30721) 2023-08-10 10:29:29 -03:00
mp_clz_tab.c
mul_1.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
preconfigure configure: Use autoconf 2.71 2023-07-17 10:08:10 -04:00
preconfigure.ac rename configure.in to configure.ac 2013-10-30 17:32:08 +10:00
rawmemchr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
rshift.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
rtld-offsets.sym x86-64: Align the stack in __tls_get_addr [BZ #21609] 2017-07-06 04:43:20 -07:00
setjmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
stackguard-macros.h BZ #15754: CVE-2013-4788 2013-09-23 00:52:09 -04:00
stackinfo.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
start.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
stpcpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
stpncpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strcasecmp_l-nonascii.c Use locale_t, not __locale_t, throughout glibc 2017-06-20 20:30:06 -04:00
strcasecmp_l.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strcasecmp.S
strcat.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strchr-isa-default-impl.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strchr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strchrnul.S string: Add libc_hidden_proto for strchrnul 2023-02-08 17:13:56 -03:00
strcmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strcpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strcspn-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strcspn.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strlen.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strncase_l-nonascii.c Use locale_t, not __locale_t, throughout glibc 2017-06-20 20:30:06 -04:00
strncase_l.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strncase.S
strncat.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strncmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strncpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strnlen.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strpbrk-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strpbrk.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strrchr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strspn-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
strspn.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sub_n.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
submul_1.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
sysdep.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tls_get_addr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tlsdesc.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tlsdesc.sym x86-64: Align the stack in __tls_get_addr [BZ #21609] 2017-07-06 04:43:20 -07:00
tst-audit3.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-audit4-aux.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-audit4.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-audit5.c Modify several tests to use test-skeleton.c 2014-11-05 15:24:08 +05:30
tst-audit6.c Modify several tests to use test-skeleton.c 2015-07-15 15:10:23 +05:30
tst-audit7.c Move x86_64-specific audit tests to sysdeps/x86_64/. 2013-04-25 19:23:11 +00:00
tst-audit10-aux.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-audit10.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-audit.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-auditmod3a.c Move x86_64-specific audit tests to sysdeps/x86_64/. 2013-04-25 19:23:11 +00:00
tst-auditmod3b.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
tst-auditmod4a.c Move x86_64-specific audit tests to sysdeps/x86_64/. 2013-04-25 19:23:11 +00:00
tst-auditmod4b.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
tst-auditmod5a.c Move x86_64-specific audit tests to sysdeps/x86_64/. 2013-04-25 19:23:11 +00:00
tst-auditmod5b.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
tst-auditmod6a.c Move x86_64-specific audit tests to sysdeps/x86_64/. 2013-04-25 19:23:11 +00:00
tst-auditmod6b.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
tst-auditmod6c.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
tst-auditmod7a.c Move x86_64-specific audit tests to sysdeps/x86_64/. 2013-04-25 19:23:11 +00:00
tst-auditmod7b.c Add missing header files throughout the testsuite. 2017-02-16 17:33:18 -05:00
tst-auditmod10a.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-auditmod10b.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-avx512-aux.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-avx512.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-avx512mod.c x86-64: Verify that _dl_runtime_resolve preserves vector registers 2017-02-09 12:19:58 -08:00
tst-avx-aux.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-avx.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-avxmod.c x86-64: Verify that _dl_runtime_resolve preserves vector registers 2017-02-09 12:19:58 -08:00
tst-glibc-hwcaps.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-platform-1.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-platformmod-1.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-platformmod-2.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-quad1.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-quad1pie.c Handle R_X86_64_RELATIVE64 and R_X86_64_64 for x32 2012-05-10 17:05:06 -07:00
tst-quad2.c Handle R_X86_64_RELATIVE64 and R_X86_64_64 for x32 2012-05-10 17:05:06 -07:00
tst-quad2pie.c Handle R_X86_64_RELATIVE64 and R_X86_64_64 for x32 2012-05-10 17:05:06 -07:00
tst-quadmod1.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-quadmod1pie.S Handle R_X86_64_RELATIVE64 and R_X86_64_64 for x32 2012-05-10 17:05:06 -07:00
tst-quadmod2.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-quadmod2pie.S Handle R_X86_64_RELATIVE64 and R_X86_64_64 for x32 2012-05-10 17:05:06 -07:00
tst-rsi-strlen.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-rsi-wcslen.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-split-dynreloc.c Fix dynamic linker issue with bind-now 2015-08-19 05:37:01 -07:00
tst-split-dynreloc.lds Fix dynamic linker issue with bind-now 2015-08-19 05:37:01 -07:00
tst-sse.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
tst-ssemod.c x86-64: Verify that _dl_runtime_resolve preserves vector registers 2017-02-09 12:19:58 -08:00
varshift.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
Versions Move __fentry__ version definition to sysdeps/{i386,x86_64} 2018-08-10 09:07:44 +02:00
wcpcpy-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcpcpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcpncpy-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcpncpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcscat-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcscat.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcschr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcscmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcscpy-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcscpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcslen.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsncat-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsncat.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsncmp-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsncmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsncpy-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsncpy.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsnlen-generic.c Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsnlen.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wcsrchr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wmemchr.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wmemcmp.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wmemset_chk.S Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00
wmemset.S x86-64: Optimize wmemset with SSE2/AVX2/AVX512 2017-06-05 11:09:59 -07:00
wordcopy.c X86-64: Add dummy memcopy.h and wordcopy.c 2016-06-09 04:38:34 -07:00
x86-lp_size.h Update copyright dates with scripts/update-copyrights 2023-01-06 21:14:39 +00:00