git: 6feb16b77e7d - main - witness: report a thread that can't sleep in WITNESS_WARN
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 05 Mar 2026 18:44:27 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=6feb16b77e7df470c635bc3af65d448fd37deb10
commit 6feb16b77e7df470c635bc3af65d448fd37deb10
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-03-05 18:43:17 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-03-05 18:43:17 +0000
witness: report a thread that can't sleep in WITNESS_WARN
Although this is not related to locking, but seems to be the right
place to catch violators, given that WITNESS_WARN is already used
widely in the kernel.
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D55316
---
sys/kern/subr_witness.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 7437a7e238f0..85dc0c321797 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -2136,6 +2136,15 @@ witness_warn(int flags, struct lock_object *lock, const char *fmt, ...)
n += witness_list_locks(&lock_list, printf);
} else
sched_unpin();
+
+ if (td->td_no_sleeping != 0 && (flags & WARN_SLEEPOK) != 0) {
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+ printf(" with %d sleep inhibitors\n", td->td_no_sleeping);
+ n += td->td_no_sleeping;
+ }
+
if (flags & WARN_PANIC && n)
kassert_panic("%s", __func__);
else