git: 71937d8e11a6 - main - libthr: Predict libthr is initialized in _thr_check_init
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 05 Nov 2026 16:00:45 UTC
The branch main has been updated by aokblast:
URL: https://cgit.FreeBSD.org/src/commit/?id=71937d8e11a6b7fdb3c1b308d5f7c8b30dac5ca7
commit 71937d8e11a6b7fdb3c1b308d5f7c8b30dac5ca7
Author: ShengYi Hung <aokblast@FreeBSD.org>
AuthorDate: 2026-11-05 15:58:18 +0000
Commit: ShengYi Hung <aokblast@FreeBSD.org>
CommitDate: 2026-11-05 16:00:27 +0000
libthr: Predict libthr is initialized in _thr_check_init
_thr_check_init() is called on hot paths such as pthread_once(), and
the uninitialized case can only happen once. Mark it with
__predict_false so the compiler lays out the initialized case as the
fall-through path.
Reviewed by: kib
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61213
---
lib/libthr/thread/thr_private.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 4469533bc40e..3cc0fe61de00 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -945,7 +945,7 @@ _thr_is_inited(void)
static inline void
_thr_check_init(void)
{
- if (_thr_initial == NULL)
+ if (__predict_false(_thr_initial == NULL))
_libpthread_init(NULL);
}