Index: sys/sys/lock_profile.h =================================================================== RCS file: /usr/home/kmacy/freebsd/ncvs/src/sys/sys/lock_profile.h,v retrieving revision 1.8 diff -d -u -r1.8 lock_profile.h --- sys/sys/lock_profile.h 16 Dec 2006 02:37:58 -0000 1.8 +++ sys/sys/lock_profile.h 23 Feb 2007 11:44:18 -0000 @@ -115,42 +115,25 @@ #endif } -static inline void lock_profile_waitstart(uint64_t *waittime) -{ - if (lock_prof_enable) - *waittime = nanoseconds(); -} - -static inline void lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested) +static inline void lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, + uint64_t *waittime) { struct lock_profile_object *l = &lo->lo_profile_obj; - if (lock_prof_enable) { - if (*contested == 0) { - atomic_add_int(&l->lpo_contest_holding, 1); - *contested = 1; - } + if (lock_prof_enable && *contested == 0) { + *waittime = nanoseconds(); + atomic_add_int(&l->lpo_contest_holding, 1); + *contested = 1; } } static inline void lock_profile_obtain_lock_success(struct lock_object *lo, uint64_t waittime, const char *file, int line) { - if (lock_prof_enable) - _lock_profile_obtain_lock_success(lo, waittime, file, line); -} - -static inline void lock_profile_update_wait(struct lock_object *lo, uint64_t waitstart) -{ - if (lock_prof_enable) - _lock_profile_update_wait(lo, waitstart); -} - -static inline void lock_profile_update_contest_locking(struct lock_object *lo, int contested) -{ if (lock_prof_enable) { + _lock_profile_obtain_lock_success(lo, contested, waittime, file, line); lo->lo_profile_obj.lpo_contest_holding = 0; if (contested) - lo->lo_profile_obj.lpo_contest_locking++; + lo->lo_profile_obj.lpo_contest_locking++; } } @@ -166,8 +149,8 @@ static inline void lock_profile_update_contest_locking(struct lock_object *lo, int contested) {;} static inline void lock_profile_waitstart(uint64_t *waittime) {;} static inline void lock_profile_release_lock(struct lock_object *lo) {;} -static inline void lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested) {;} -static inline void lock_profile_obtain_lock_success(struct lock_object *lo, uint64_t waittime, +static inline void lock_profile_obtain_lock_failed(struct lock_object *lo, int *contested, uint64_t *waittime) {;} +static inline void lock_profile_obtain_lock_success(struct lock_object *lo, int contested, uint64_t waittime, const char *file, int line) {;} static inline void lock_profile_object_destroy(struct lock_object *lo) {;} static inline void lock_profile_object_init(struct lock_object *lo, struct lock_class *class, const char *name) {;} Index: sys/sys/mutex.h =================================================================== RCS file: /usr/home/kmacy/freebsd/ncvs/src/sys/sys/mutex.h,v retrieving revision 1.87 diff -d -u -r1.87 mutex.h --- sys/sys/mutex.h 21 Dec 2006 22:42:18 -0000 1.87 +++ sys/sys/mutex.h 23 Feb 2007 12:10:25 -0000 @@ -156,9 +156,13 @@ #ifndef _get_sleep_lock #define _get_sleep_lock(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ - \ - if (!_obtain_lock((mp), _tid)) \ + int contested = 0; \ + uint64_t waittime = 0; \ + if (!_obtain_lock((mp), _tid)) { \ + 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);\ } while (0) #endif @@ -171,19 +175,20 @@ */ #ifndef _get_spin_lock #ifdef SMP -#define _get_spin_lock(mp, tid, opts, file, line) do { \ +#define _get_spin_lock(mp, tid, opts, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ - int contested = 0; \ - \ + int contested = 0; \ + uint64_t waittime = 0; \ spinlock_enter(); \ if (!_obtain_lock((mp), _tid)) { \ - lock_profile_obtain_lock_failed(&mp->mtx_object, &contested);\ if ((mp)->mtx_lock == _tid) \ (mp)->mtx_recurse++; \ - else \ + else { \ + lock_profile_obtain_lock_failed(&(mp)->mtx_object, &contested, &waittime); \ _mtx_lock_spin((mp), _tid, (opts), (file), (line)); \ + } \ } \ - lock_profile_update_contest_locking(&mp->mtx_object, contested);\ + 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/sys/rwlock.h =================================================================== RCS file: /usr/home/kmacy/freebsd/ncvs/src/sys/sys/rwlock.h,v retrieving revision 1.5 diff -d -u -r1.5 rwlock.h --- sys/sys/rwlock.h 13 Oct 2006 19:43:35 -0000 1.5 +++ sys/sys/rwlock.h 23 Feb 2007 11:52:21 -0000 @@ -95,11 +95,13 @@ */ /* Acquire a write lock. */ -#define __rw_wlock(rw, tid, file, line) do { \ +#define __rw_wlock(rw, tid, contested, waitstart, file, line) do { \ uintptr_t _tid = (uintptr_t)(tid); \ \ - if (!_rw_write_lock((rw), _tid)) \ + if (!_rw_write_lock((rw), _tid)) { \ + lock_profile_obtain_lock_failed(&(rw)->rw_object, contested, waitstart); \ _rw_wlock_hard((rw), _tid, (file), (line)); \ + } \ } while (0) /* Release a write lock. */