diff options
| author | Gleb Smirnoff <glebius@FreeBSD.org> | 2026-03-05 18:43:17 +0000 |
|---|---|---|
| committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2026-03-05 18:43:17 +0000 |
| commit | 6feb16b77e7df470c635bc3af65d448fd37deb10 (patch) | |
| tree | 180d6b1d76574c392c3e22284a71cbbd1a9d0185 | |
| parent | 0616521adc35cb252cb399f1147f103284f0f188 (diff) | |
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
| -rw-r--r-- | sys/kern/subr_witness.c | 9 |
1 files changed, 9 insertions, 0 deletions
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 |
