Index: kern/kern_rwlock.c =================================================================== RCS file: /usr/cvs/src/sys/kern/kern_rwlock.c,v retrieving revision 1.15 diff -u -r1.15 kern_rwlock.c --- kern/kern_rwlock.c 27 Feb 2007 06:42:04 -0000 1.15 +++ kern/kern_rwlock.c 27 Feb 2007 22:13:03 -0000 @@ -150,7 +150,7 @@ #ifdef SMP volatile struct thread *owner; #endif - uint64_t waitstart = 0; + uint64_t waittime = 0; int contested = 0; uintptr_t x; @@ -192,18 +192,22 @@ MPASS((x & RW_LOCK_READ_WAITERS) == 0); if (atomic_cmpset_acq_ptr(&rw->rw_lock, x, x + RW_ONE_READER)) { - lock_profile_obtain_lock_success(&rw->rw_object, contested, waitstart, file, line); if (LOCK_LOG_TEST(&rw->rw_object, 0)) CTR4(KTR_LOCK, "%s: %p succeed %p -> %p", __func__, rw, (void *)x, (void *)(x + RW_ONE_READER)); + if (RW_READERS(x) == 0) + lock_profile_obtain_lock_success( + &rw->rw_object, contested, waittime, + file, line); break; } - lock_profile_obtain_lock_failed(&rw->rw_object, &contested, &waitstart); cpu_spinwait(); continue; } + lock_profile_obtain_lock_failed(&rw->rw_object, &contested, + &waittime); /* * Okay, now it's the hard case. Some other thread already @@ -250,7 +254,6 @@ */ owner = (struct thread *)RW_OWNER(x); if (TD_IS_RUNNING(owner)) { - lock_profile_obtain_lock_failed(&rw->rw_object, &contested, &waitstart); turnstile_release(&rw->rw_object); if (LOCK_LOG_TEST(&rw->rw_object, 0)) CTR3(KTR_LOCK, "%s: spinning on %p held by %p", @@ -316,8 +319,7 @@ break; } continue; - } else - lock_profile_release_lock(&rw->rw_object); + } /* @@ -401,6 +403,7 @@ turnstile_unpend(ts, TS_SHARED_LOCK); break; } + lock_profile_release_lock(&rw->rw_object); } /* Index: sys/mutex.h =================================================================== RCS file: /usr/cvs/src/sys/sys/mutex.h,v retrieving revision 1.89 diff -u -r1.89 mutex.h --- sys/mutex.h 27 Feb 2007 01:48:58 -0000 1.89 +++ sys/mutex.h 27 Feb 2007 22:04:11 -0000 @@ -159,10 +159,12 @@ int contested = 0; \ uint64_t waittime = 0; \ if (!_obtain_lock((mp), _tid)) { \ - lock_profile_obtain_lock_failed(&(mp)->mtx_object, &contested, &waittime); \ + lock_profile_obtain_lock_failed(&(mp)->mtx_object, \ + &contested, &waittime); \ _mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \ } \ - lock_profile_obtain_lock_success(&(mp)->mtx_object, contested, waittime, file, line); \ + lock_profile_obtain_lock_success(&(mp)->mtx_object, contested, \ + waittime, (file), (line)); \ } while (0) #endif @@ -184,11 +186,13 @@ if ((mp)->mtx_lock == _tid) \ (mp)->mtx_recurse++; \ else { \ - lock_profile_obtain_lock_failed(&(mp)->mtx_object, &contested, &waittime); \ + lock_profile_obtain_lock_failed(&(mp)->mtx_object, \ + &contested, &waittime); \ _mtx_lock_spin((mp), _tid, (opts), (file), (line)); \ } \ } \ - lock_profile_obtain_lock_success(&(mp)->mtx_object, contested, waittime, file, line); \ + lock_profile_obtain_lock_success(&(mp)->mtx_object, contested, \ + waittime, (file), (line)); \ } while (0) #else /* SMP */ #define _get_spin_lock(mp, tid, opts, file, line) do { \ Index: sys/rwlock.h =================================================================== RCS file: /usr/cvs/src/sys/sys/rwlock.h,v retrieving revision 1.7 diff -u -r1.7 rwlock.h --- sys/rwlock.h 26 Feb 2007 19:05:13 -0000 1.7 +++ sys/rwlock.h 27 Feb 2007 22:03:52 -0000 @@ -101,10 +101,12 @@ uint64_t waitstart = 0; \ \ if (!_rw_write_lock((rw), _tid)) { \ - lock_profile_obtain_lock_failed(&(rw)->rw_object, &contested, &waitstart); \ + lock_profile_obtain_lock_failed(&(rw)->rw_object, \ + &contested, &waitstart); \ _rw_wlock_hard((rw), _tid, (file), (line)); \ } \ - lock_profile_obtain_lock_success(&rw->rw_object, contested, waitstart, file, line); \ + lock_profile_obtain_lock_success(&(rw)->rw_object, contested, \ + waitstart, (file), (line)); \ } while (0) /* Release a write lock. */