Index: kern_umtx.c =================================================================== --- kern_umtx.c (revision 197734) +++ kern_umtx.c (working copy) @@ -2444,11 +2444,17 @@ /* try to lock it */ while (!(state & wrflags)) { if (__predict_false(URWLOCK_READER_COUNT(state) == URWLOCK_MAX_READERS)) { + CTR2(KTR_SPARE2, + "td = %p, lock = %p, MaxReaders reached", + curthread, rwlock); umtx_key_release(&uq->uq_key); return (EAGAIN); } oldstate = casuword32(&rwlock->rw_state, state, state + 1); if (oldstate == state) { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, state + 1); umtx_key_release(&uq->uq_key); return (0); } @@ -2466,13 +2472,21 @@ /* set read contention bit */ while ((state & wrflags) && !(state & URWLOCK_READ_WAITERS)) { oldstate = casuword32(&rwlock->rw_state, state, state | URWLOCK_READ_WAITERS); - if (oldstate == state) + if (oldstate == state) { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, + state | URWLOCK_READ_WAITERS); goto sleep; + } state = oldstate; } /* state is changed while setting flags, restart */ if (!(state & wrflags)) { + CTR2(KTR_SPARE2, + "td = %p, lock = %p State Changed While Setting FR", + curthread, rwlock); umtxq_lock(&uq->uq_key); umtxq_unbusy(&uq->uq_key); umtxq_unlock(&uq->uq_key); @@ -2507,8 +2521,13 @@ for (;;) { oldstate = casuword32(&rwlock->rw_state, state, state & ~URWLOCK_READ_WAITERS); - if (oldstate == state) + if (oldstate == state) { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, + state & ~URWLOCK_READ_WAITERS); break; + } state = oldstate; } } @@ -2569,6 +2588,10 @@ while (!(state & URWLOCK_WRITE_OWNER) && URWLOCK_READER_COUNT(state) == 0) { oldstate = casuword32(&rwlock->rw_state, state, state | URWLOCK_WRITE_OWNER); if (oldstate == state) { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, + state | URWLOCK_WRITE_OWNER); umtx_key_release(&uq->uq_key); return (0); } @@ -2586,12 +2609,20 @@ while (((state & URWLOCK_WRITE_OWNER) || URWLOCK_READER_COUNT(state) != 0) && (state & URWLOCK_WRITE_WAITERS) == 0) { oldstate = casuword32(&rwlock->rw_state, state, state | URWLOCK_WRITE_WAITERS); - if (oldstate == state) + if (oldstate == state) { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, + state | URWLOCK_WRITE_WAITERS); goto sleep; + } state = oldstate; } if (!(state & URWLOCK_WRITE_OWNER) && URWLOCK_READER_COUNT(state) == 0) { + CTR2(KTR_SPARE2, + "td = %p, lock = %p State Changed While Setting FW", + curthread, rwlock); umtxq_lock(&uq->uq_key); umtxq_unbusy(&uq->uq_key); umtxq_unlock(&uq->uq_key); @@ -2623,8 +2654,13 @@ for (;;) { oldstate = casuword32(&rwlock->rw_state, state, state & ~URWLOCK_WRITE_WAITERS); - if (oldstate == state) + if (oldstate == state) { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, + state & ~URWLOCK_WRITE_WAITERS); break; + } state = oldstate; } } @@ -2691,8 +2727,13 @@ error = EPERM; goto out; } - } else + } else { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, + state & ~URWLOCK_WRITE_OWNER); break; + } } } else if (URWLOCK_READER_COUNT(state) != 0) { for (;;) { @@ -2705,8 +2746,12 @@ goto out; } } - else + else { + CTR4(KTR_SPARE2, + "td = %p, lock = %p, oldstate: 0x%x state: 0x%x", + curthread, rwlock, state, state - 1); break; + } } } else { error = EPERM;