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
This commit is contained in:
Gleb Smirnoff
2026-03-05 10:43:17 -08:00
parent 0616521adc
commit 6feb16b77e
+9
View File
@@ -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