svn commit: r356375 - in head/sys: amd64/amd64 kern sys
Mateusz Guzik
mjg at FreeBSD.org
Sun Jan 5 12:48:21 UTC 2020
Author: mjg
Date: Sun Jan 5 12:48:19 2020
New Revision: 356375
URL: https://svnweb.freebsd.org/changeset/base/356375
Log:
locks: add default delay struct
Use it for all primitives. This makes everything fit in 8 bytes.
Modified:
head/sys/amd64/amd64/pmap.c
head/sys/kern/kern_mutex.c
head/sys/kern/kern_rwlock.c
head/sys/kern/kern_sx.c
head/sys/kern/subr_lock.c
head/sys/sys/lock.h
Modified: head/sys/amd64/amd64/pmap.c
==============================================================================
--- head/sys/amd64/amd64/pmap.c Sun Jan 5 12:47:29 2020 (r356374)
+++ head/sys/amd64/amd64/pmap.c Sun Jan 5 12:48:19 2020 (r356375)
@@ -763,8 +763,7 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, invl_max_qlen, CTLFLAG_
"");
#endif
-static struct lock_delay_config __read_frequently di_delay;
-LOCK_DELAY_SYSINIT_DEFAULT(di_delay);
+#define di_delay locks_delay
static void
pmap_delayed_invl_start_u(void)
Modified: head/sys/kern/kern_mutex.c
==============================================================================
--- head/sys/kern/kern_mutex.c Sun Jan 5 12:47:29 2020 (r356374)
+++ head/sys/kern/kern_mutex.c Sun Jan 5 12:48:19 2020 (r356375)
@@ -140,6 +140,7 @@ struct lock_class lock_class_mtx_spin = {
};
#ifdef ADAPTIVE_MUTEXES
+#ifdef MUTEX_CUSTOM_BACKOFF
static SYSCTL_NODE(_debug, OID_AUTO, mtx, CTLFLAG_RD, NULL, "mtx debugging");
static struct lock_delay_config __read_frequently mtx_delay;
@@ -150,8 +151,12 @@ SYSCTL_U16(_debug_mtx, OID_AUTO, delay_max, CTLFLAG_RW
0, "");
LOCK_DELAY_SYSINIT_DEFAULT(mtx_delay);
+#else
+#define mtx_delay locks_delay
#endif
+#endif
+#ifdef MUTEX_SPIN_CUSTOM_BACKOFF
static SYSCTL_NODE(_debug, OID_AUTO, mtx_spin, CTLFLAG_RD, NULL,
"mtx spin debugging");
@@ -163,6 +168,9 @@ SYSCTL_INT(_debug_mtx_spin, OID_AUTO, delay_max, CTLFL
&mtx_spin_delay.max, 0, "");
LOCK_DELAY_SYSINIT_DEFAULT(mtx_spin_delay);
+#else
+#define mtx_spin_delay locks_delay
+#endif
/*
* System-wide mutexes
Modified: head/sys/kern/kern_rwlock.c
==============================================================================
--- head/sys/kern/kern_rwlock.c Sun Jan 5 12:47:29 2020 (r356374)
+++ head/sys/kern/kern_rwlock.c Sun Jan 5 12:48:19 2020 (r356375)
@@ -94,6 +94,7 @@ struct lock_class lock_class_rw = {
};
#ifdef ADAPTIVE_RWLOCKS
+#ifdef RWLOCK_CUSTOM_BACKOFF
static u_short __read_frequently rowner_retries;
static u_short __read_frequently rowner_loops;
static SYSCTL_NODE(_debug, OID_AUTO, rwlock, CTLFLAG_RD, NULL,
@@ -117,6 +118,11 @@ rw_lock_delay_init(void *arg __unused)
rowner_loops = max(10000, rw_delay.max);
}
LOCK_DELAY_SYSINIT(rw_lock_delay_init);
+#else
+#define rw_delay locks_delay
+#define rowner_retries locks_delay_retries
+#define rowner_loops locks_delay_loops
+#endif
#endif
/*
Modified: head/sys/kern/kern_sx.c
==============================================================================
--- head/sys/kern/kern_sx.c Sun Jan 5 12:47:29 2020 (r356374)
+++ head/sys/kern/kern_sx.c Sun Jan 5 12:48:19 2020 (r356375)
@@ -143,6 +143,7 @@ struct lock_class lock_class_sx = {
#endif
#ifdef ADAPTIVE_SX
+#ifdef SX_CUSTOM_BACKOFF
static u_short __read_frequently asx_retries;
static u_short __read_frequently asx_loops;
static SYSCTL_NODE(_debug, OID_AUTO, sx, CTLFLAG_RD, NULL, "sxlock debugging");
@@ -165,6 +166,11 @@ sx_lock_delay_init(void *arg __unused)
asx_loops = max(10000, sx_delay.max);
}
LOCK_DELAY_SYSINIT(sx_lock_delay_init);
+#else
+#define sx_delay locks_delay
+#define asx_retries locks_delay_retries
+#define asx_loops locks_delay_loops
+#endif
#endif
void
Modified: head/sys/kern/subr_lock.c
==============================================================================
--- head/sys/kern/subr_lock.c Sun Jan 5 12:47:29 2020 (r356374)
+++ head/sys/kern/subr_lock.c Sun Jan 5 12:48:19 2020 (r356375)
@@ -161,6 +161,29 @@ lock_delay_default_init(struct lock_delay_config *lc)
lc->max = 32678;
}
+struct lock_delay_config __read_frequently locks_delay;
+u_short __read_frequently locks_delay_retries;
+u_short __read_frequently locks_delay_loops;
+
+SYSCTL_U16(_debug_lock, OID_AUTO, delay_base, CTLFLAG_RW, &locks_delay.base,
+ 0, "");
+SYSCTL_U16(_debug_lock, OID_AUTO, delay_max, CTLFLAG_RW, &locks_delay.max,
+ 0, "");
+SYSCTL_U16(_debug_lock, OID_AUTO, delay_retries, CTLFLAG_RW, &locks_delay_retries,
+ 0, "");
+SYSCTL_U16(_debug_lock, OID_AUTO, delay_loops, CTLFLAG_RW, &locks_delay_loops,
+ 0, "");
+
+static void
+locks_delay_init(void *arg __unused)
+{
+
+ lock_delay_default_init(&locks_delay);
+ locks_delay_retries = 10;
+ locks_delay_loops = max(10000, locks_delay.max);
+}
+LOCK_DELAY_SYSINIT(locks_delay_init);
+
#ifdef DDB
DB_SHOW_COMMAND(lock, db_show_lock)
{
Modified: head/sys/sys/lock.h
==============================================================================
--- head/sys/sys/lock.h Sun Jan 5 12:47:29 2020 (r356374)
+++ head/sys/sys/lock.h Sun Jan 5 12:48:19 2020 (r356375)
@@ -187,6 +187,10 @@ struct lock_delay_config {
u_short max;
};
+extern struct lock_delay_config locks_delay;
+extern u_short locks_delay_retries;
+extern u_short locks_delay_loops;
+
struct lock_delay_arg {
struct lock_delay_config *config;
u_short delay;
More information about the svn-src-all
mailing list