--- //depot/vendor/freebsd/src/sys/kern/kern_rwlock.c 2007/11/26 22:44:43 +++ //depot/user/attilio/attilio_schedlock/kern/kern_rwlock.c 2007/11/29 20:29:57 @@ -238,19 +238,9 @@ KASSERT(rw_wowner(rw) != curthread, ("%s (%s): wlock already held @ %s:%d", __func__, rw->lock_object.lo_name, file, line)); - WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER, file, line); + WITNESS_CHECKORDER(&rw->lock_object, LOP_NEWORDER | LOP_NORECURSE, + file, line); - /* - * Note that we don't make any attempt to try to block read - * locks once a writer has blocked on the lock. The reason is - * that we currently allow for read locks to recurse and we - * don't keep track of all the holders of read locks. Thus, if - * we were to block readers once a writer blocked and a reader - * tried to recurse on their reader lock after a writer had - * blocked we would end up in a deadlock since the reader would - * be blocked on the writer, and the writer would be blocked - * waiting for the reader to release its original read lock. - */ for (;;) { /* * Handle the easy case. If no other thread has a write --- //depot/vendor/freebsd/src/sys/kern/subr_witness.c 2007/11/24 04:37:19 +++ //depot/user/attilio/attilio_schedlock/kern/subr_witness.c 2007/11/29 20:29:57 @@ -922,6 +922,9 @@ lock1->li_file, lock1->li_line); panic("excl->share"); } + if (flags & LOP_NORECURSE) + panic("recurse on non-recursive lock %s @ %s:%d", + lock->lo_name, file, line); return; } --- //depot/vendor/freebsd/src/sys/sys/lock.h 2007/11/18 14:44:31 +++ //depot/user/attilio/attilio_schedlock/sys/lock.h 2007/11/29 20:29:57 @@ -103,6 +103,7 @@ #define LOP_TRYLOCK 0x00000004 /* Don't check lock order. */ #define LOP_EXCLUSIVE 0x00000008 /* Exclusive lock. */ #define LOP_DUPOK 0x00000010 /* Don't check for duplicate acquires */ +#define LOP_NORECURSE 0x00000020 /* Don't allow recursion for the lock */ /* Flags passed to witness_assert. */ #define LA_UNLOCKED 0x00000000 /* Lock is unlocked. */