git: 792c94293e21 - main - sys/conf/options: Add WITNESS_LOCK_CHILDCOUNT
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 02 Sep 2026 14:06:54 UTC
The branch main has been updated by ziaee:
URL: https://cgit.FreeBSD.org/src/commit/?id=792c94293e217d77d9eb8871ce3b53898ece0f9a
commit 792c94293e217d77d9eb8871ce3b53898ece0f9a
Author: Kajetan Puchalski <kajetan.puchalski@arm.com>
AuthorDate: 2026-08-27 14:37:14 +0000
Commit: Alexander Ziaee <ziaee@FreeBSD.org>
CommitDate: 2026-09-02 14:04:45 +0000
sys/conf/options: Add WITNESS_LOCK_CHILDCOUNT
Make the witness LOCK_CHILDCOUNT a configurable kernel option.
On machines with a very high core count the default value is too
low, leading to witness exhaustion after boot.
Relnotes: yes
Reviewed by: kib, ziaee
Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
Closes: https://github.com/freebsd/freebsd-src/pull/2398
---
share/man/man4/witness.4 | 14 +++++++++++++-
sys/conf/options | 1 +
sys/kern/subr_witness.c | 14 ++++++++++----
3 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/share/man/man4/witness.4 b/share/man/man4/witness.4
index 9016da3b39c6..c777d116f7ec 100644
--- a/share/man/man4/witness.4
+++ b/share/man/man4/witness.4
@@ -21,7 +21,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 26, 2026
+.Dd September 1, 2026
.Dt WITNESS 4
.Os
.Sh NAME
@@ -30,6 +30,7 @@
.Sh SYNOPSIS
.Cd options WITNESS
.Cd options WITNESS_COUNT
+.Cd options WITNESS_LOCK_CHILDCOUNT=number
.Cd options WITNESS_KDB
.Cd options WITNESS_NO_VNODE
.Cd options WITNESS_SKIPSPIN
@@ -71,6 +72,17 @@ via the
environment variable.
.Pp
The
+.Dv WITNESS_LOCK_CHILDCOUNT
+kernel option specifies the number of entries in the statically allocated
+pool used by
+.Nm
+to record lock-order relationships.
+The value must be greater than zero.
+The default is 2048.
+Increasing this value permits more relationships to be tracked at the cost
+of additional kernel memory.
+.Pp
+The
.Dv WITNESS_NO_VNODE
kernel option tells
.Nm
diff --git a/sys/conf/options b/sys/conf/options
index 8a9bee6ff5d3..03b9f1472904 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -702,6 +702,7 @@ WITNESS_KDB opt_witness.h
WITNESS_NO_VNODE opt_witness.h
WITNESS_SKIPSPIN opt_witness.h
WITNESS_COUNT opt_witness.h
+WITNESS_LOCK_CHILDCOUNT opt_witness.h
OPENSOLARIS_WITNESS opt_global.h
EPOCH_TRACE opt_global.h
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 92fa8c0799d8..9825db85b673 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -148,7 +148,13 @@
* probably be safe for the most part, but it's still a SWAG.
*/
#define LOCK_NCHILDREN 5
-#define LOCK_CHILDCOUNT 2048
+#ifndef WITNESS_LOCK_CHILDCOUNT
+#define WITNESS_LOCK_CHILDCOUNT 2048
+#endif
+
+#if WITNESS_LOCK_CHILDCOUNT < 1
+ #error "WITNESS_LOCK_CHILDCOUNT must be greater than zero"
+#endif
#define MAX_W_NAME 64
@@ -484,7 +490,7 @@ SYSCTL_INT(_debug_witness, OID_AUTO, sleep_cnt, CTLFLAG_RD, &w_sleep_cnt, 0,
static struct witness *w_data;
static uint8_t **w_rmatrix;
-static struct lock_list_entry w_locklistdata[LOCK_CHILDCOUNT];
+static struct lock_list_entry w_locklistdata[WITNESS_LOCK_CHILDCOUNT];
static struct witness_hash w_hash; /* The witness hash table. */
static u_long w_sz; /* Witness startup memory allocation size */
@@ -928,7 +934,7 @@ witness_startup(void *mem)
(witness_count + 1));
}
- for (i = 0; i < LOCK_CHILDCOUNT; i++)
+ for (i = 0; i < WITNESS_LOCK_CHILDCOUNT; i++)
witness_lock_list_free(&w_locklistdata[i]);
witness_init_hash_tables();
@@ -1611,7 +1617,7 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file,
int trace;
bool pstackv;
- MPASS(j < LOCK_CHILDCOUNT * LOCK_NCHILDREN);
+ MPASS(j < WITNESS_LOCK_CHILDCOUNT * LOCK_NCHILDREN);
lock1 = &lle->ll_children[i];
/*