summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-01-05 12:48:19 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-01-05 12:48:19 +0000
commit2e77cad11dc5ec9c14c074dfc127f8420075aa7c (patch)
treec160653223c1bbca4cc10daa6ff08b908f8a3f5f
parent6b8dd26e7c5f2caf9e5094d6fa15d8edcace65a0 (diff)
Notes
-rw-r--r--sys/amd64/amd64/pmap.c3
-rw-r--r--sys/kern/kern_mutex.c8
-rw-r--r--sys/kern/kern_rwlock.c6
-rw-r--r--sys/kern/kern_sx.c6
-rw-r--r--sys/kern/subr_lock.c23
-rw-r--r--sys/sys/lock.h4
6 files changed, 48 insertions, 2 deletions
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index f78caf24d05b..78166ea75447 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -763,8 +763,7 @@ SYSCTL_INT(_vm_pmap, OID_AUTO, invl_max_qlen, CTLFLAG_RD,
"");
#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)
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 792b13956337..b38dee68e16e 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -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, &mtx_delay.max,
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, CTLFLAG_RW,
&mtx_spin_delay.max, 0, "");
LOCK_DELAY_SYSINIT_DEFAULT(mtx_spin_delay);
+#else
+#define mtx_spin_delay locks_delay
+#endif
/*
* System-wide mutexes
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index f8f0025d0ed8..b6fd7b1593e2 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -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
/*
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index b0ae2c987f2f..383567b64d31 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -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
diff --git a/sys/kern/subr_lock.c b/sys/kern/subr_lock.c
index 669b89d9c165..3d6e86419867 100644
--- a/sys/kern/subr_lock.c
+++ b/sys/kern/subr_lock.c
@@ -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)
{
diff --git a/sys/sys/lock.h b/sys/sys/lock.h
index 001d1e23af40..e82ff7db4825 100644
--- a/sys/sys/lock.h
+++ b/sys/sys/lock.h
@@ -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;