git: 56ac3351c61f - main - witness: fix operation without WITNESS_SKIPSPIN

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Fri, 17 Jul 2026 01:40:13 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=56ac3351c61f285ee5b8c9bd4411eeaeb20efe26

commit 56ac3351c61f285ee5b8c9bd4411eeaeb20efe26
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-07-17 01:37:03 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-07-17 01:37:03 +0000

    witness: fix operation without WITNESS_SKIPSPIN
    
    Since malloc(9) even with M_NOWAIT is forbidden when we hold a spinlock,
    we can't print detailed lock tree as the operation tries to allocate
    memory.
    
    Fixes:  fb4b0c91195195561560bb2fb2c1ba8da81f7ccf
---
 sys/kern/subr_witness.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c
index 52f8fa51fd25..92fa8c0799d8 100644
--- a/sys/kern/subr_witness.c
+++ b/sys/kern/subr_witness.c
@@ -1738,7 +1738,8 @@ witness_checkorder(struct lock_object *lock, int flags, const char *file,
 		"lock order reversal: (Giant after non-sleepable)\n");
 			else {
 				witness_output("lock order reversal:\n");
-				print_lock_order = true;
+				if (lock_list == td->td_sleeplocks)
+					print_lock_order = true;
 			}
 
 			/*