git: 642cd511028b - main - libthr: Add src.conf variable WITHOUT_PTHREADS_ASSERTIONS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 07 Jul 2023 01:45:57 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=642cd511028b8839db2c89a44cf7807d80664f38
commit 642cd511028b8839db2c89a44cf7807d80664f38
Author: Greg Becker <becker.greg@att.net>
AuthorDate: 2023-07-07 00:30:02 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-07-07 01:45:09 +0000
libthr: Add src.conf variable WITHOUT_PTHREADS_ASSERTIONS
This patch fixes a bug which prevents building libthr without
_PTHREADS_INVARIANTS defined. The default remains to build libthr
with -D_PTHREADS_INVARIANTS. However, with this patch, if one builds
libthr with WITHOUT_PTHREADS_ASSERTIONS=true then the latency to
acquire+release a default pthread mutex is reduced by roughly 5%, and a
robust mutex by roughly 18% (as measured by a simple synthetic test on a
Xeon E5-2697a based machine).
Reviewed by: jhb, kib, mjg
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D40900
---
lib/libthr/Makefile | 2 ++
lib/libthr/thread/thr_mutex.c | 2 +-
share/mk/src.opts.mk | 1 +
tools/build/options/WITHOUT_PTHREADS_ASSERTIONS | 1 +
4 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/libthr/Makefile b/lib/libthr/Makefile
index 062f5eec5d88..6337c87d5d6f 100644
--- a/lib/libthr/Makefile
+++ b/lib/libthr/Makefile
@@ -51,8 +51,10 @@ SYMBOL_MAPS=${.CURDIR}/pthread.map
MAN= libthr.3
+.if ${MK_PTHREADS_ASSERTIONS} != "no"
# enable extra internal consistency checks
CFLAGS+=-D_PTHREADS_INVARIANTS
+.endif
PRECIOUSLIB=
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index 8dccdf4dfa8c..2cbfd9a459d3 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -120,7 +120,7 @@ __weak_reference(_pthread_mutex_getyieldloops_np, pthread_mutex_getyieldloops_np
__weak_reference(_pthread_mutex_isowned_np, pthread_mutex_isowned_np);
static void
-mutex_init_link(struct pthread_mutex *m)
+mutex_init_link(struct pthread_mutex *m __unused)
{
#if defined(_PTHREADS_INVARIANTS)
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index 3c17f9319619..0e9b5a052ffc 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -159,6 +159,7 @@ __DEFAULT_YES_OPTIONS = \
PKGBOOTSTRAP \
PMC \
PPP \
+ PTHREADS_ASSERTIONS \
QUOTAS \
RADIUS_SUPPORT \
RBOOTD \
diff --git a/tools/build/options/WITHOUT_PTHREADS_ASSERTIONS b/tools/build/options/WITHOUT_PTHREADS_ASSERTIONS
new file mode 100644
index 000000000000..b0961fa43cb6
--- /dev/null
+++ b/tools/build/options/WITHOUT_PTHREADS_ASSERTIONS
@@ -0,0 +1 @@
+Disable debugging assertions in pthreads library.