summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/conf/NOTES6
-rw-r--r--sys/conf/options1
-rw-r--r--sys/kern/kern_mutex.c4
3 files changed, 11 insertions, 0 deletions
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 53e13ef..0f37fcc 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -173,6 +173,12 @@ options SMP # Symmetric MultiProcessor Kernel
# to disable it.
options NO_ADAPTIVE_MUTEXES
+# ADAPTIVE_GIANT causes the Giant lock to also be made adaptive when
+# running without NO_ADAPTIVE_MUTEXES. Normally, because Giant is assumed
+# to be held for extended periods, contention on Giant will cause a thread
+# to sleep rather than spinning.
+options ADAPTIVE_GIANT
+
# MUTEX_NOINLINE forces mutex operations to call functions to perform each
# operation rather than inlining the simple cases. This can be used to
# shrink the size of the kernel text segment. Note that this behavior is
diff --git a/sys/conf/options b/sys/conf/options
index 63fb9b5..ef15023 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -56,6 +56,7 @@ KDB_TRACE opt_kdb.h
KDB_UNATTENDED opt_kdb.h
# Miscellaneous options.
+ADAPTIVE_GIANT opt_adaptive_mutexes.h
NO_ADAPTIVE_MUTEXES opt_adaptive_mutexes.h
ALQ
CODA_COMPAT_5 opt_coda.h
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index c6f7b3e..507df8a 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -509,7 +509,11 @@ _mtx_lock_sleep(struct mtx *m, int opts, const char *file, int line)
* CPU, spin instead of blocking.
*/
owner = (struct thread *)(v & MTX_FLAGMASK);
+#ifdef ADAPTIVE_GIANT
+ if (TD_IS_RUNNING(owner)) {
+#else
if (m != &Giant && TD_IS_RUNNING(owner)) {
+#endif
turnstile_release(&m->mtx_object);
while (mtx_owner(m) == owner && TD_IS_RUNNING(owner)) {
#if defined(__i386__) || defined(__amd64__)
OpenPOWER on IntegriCloud