git: 19419d36cf2a - main - libc: Give __thr_jtable protected visibility
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 19 May 2025 15:01:55 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=19419d36cf2a132a325c0a66f49c3a66043072ba
commit 19419d36cf2a132a325c0a66f49c3a66043072ba
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-05-19 14:29:12 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-05-19 14:29:12 +0000
libc: Give __thr_jtable protected visibility
This function pointer table is overwritten by libthr when it's loaded.
libc's pthread stubs are implemented by looking up an entry in this
table and invoking the function pointer contained in the entry.
pthread calls are fairly expensive even when libthr is not loaded: each
call involves indirection through the PLT, then through the GOT to look
up __thr_jtable, then the function pointer itself. We can however
eliminate one level of indirection by disallowing preemption of the
__thr_jtable symbol, and since the existence table is an internal
implementation detail, disabling preemption is unlikely to break
anything. This gives a modest improvement in some microbenchmarks which
call libc's pthread stubs.
Reviewed by: kib
MFC after: 1 month
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D50354
---
lib/libc/gen/_pthread_stubs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c
index 2a0cebadd5fd..d867ee4db51e 100644
--- a/lib/libc/gen/_pthread_stubs.c
+++ b/lib/libc/gen/_pthread_stubs.c
@@ -63,6 +63,7 @@ static int stub_getname_np(pthread_t, char *, size_t);
#define PJT_DUAL_ENTRY(entry) \
(pthread_func_t)entry, (pthread_func_t)entry
+__attribute__((visibility("protected")))
pthread_func_entry_t __thr_jtable[PJT_MAX] = {
[PJT_ATFORK] = {PJT_DUAL_ENTRY(stub_zero)},
[PJT_ATTR_DESTROY] = {PJT_DUAL_ENTRY(stub_zero)},