Diagnostic function rw_enter_diag() should be called before
WITNESS_CHECKORDER() to have proper locking/debugging information.

In the case of 'locking against myself' it is currently impossible
to know where the lock has been previously acquired.  Diff below fixes
that, ok?

Index: kern/kern_rwlock.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_rwlock.c,v
retrieving revision 1.47
diff -u -p -r1.47 kern_rwlock.c
--- kern/kern_rwlock.c  8 Feb 2021 08:18:45 -0000       1.47
+++ kern/kern_rwlock.c  15 Feb 2021 10:32:57 -0000
@@ -237,7 +237,11 @@ rw_enter(struct rwlock *rwl, int flags)
        int error, prio;
 #ifdef WITNESS
        int lop_flags;
+#endif
+
+       rw_enter_diag(rwl, flags);
 
+#ifdef WITNESS
        lop_flags = LOP_NEWORDER;
        if (flags & RW_WRITE)
                lop_flags |= LOP_EXCLUSIVE;
@@ -270,8 +274,6 @@ retry:
                        continue;
                }
 #endif
-
-               rw_enter_diag(rwl, flags);
 
                if (flags & RW_NOSLEEP)
                        return (EBUSY);

Reply via email to