===================================================================== Add kern_lockstat.c. --------------------------------------------------------------------- --- /u/freebsd/head/src/sys/conf/files 2008-05-21 07:25:51.000000000 +1000 +++ /u/p4/dtrace/src/sys/conf/files 2008-05-21 07:27:18.000000000 +1000 @@ -1632,6 +1632,7 @@ kern/kern_linker.c standard kern/kern_lock.c standard kern/kern_lockf.c standard +kern/kern_lockstat.c optional kdtrace_hooks kern/kern_malloc.c standard kern/kern_mbuf.c standard kern/kern_mib.c standard ===================================================================== lockstat support --------------------------------------------------------------------- --- /u/freebsd/head/src/sys/sys/mutex.h 2008-05-17 11:54:42.000000000 +1000 +++ /u/p4/dtrace/src/sys/sys/mutex.h 2008-05-17 11:54:48.000000000 +1000 @@ -168,9 +168,11 @@ uintptr_t _tid = (uintptr_t)(tid); \ if (!_obtain_lock((mp), _tid)) { \ _mtx_lock_sleep((mp), _tid, (opts), (file), (line)); \ - } else \ + } else { \ lock_profile_obtain_lock_success(&(mp)->lock_object, 0, \ 0, (file), (line)); \ + LOCKSTAT_RECORD0(LS_MTX_LOCK_ACQUIRE, mp); \ + } \ } while (0) #endif @@ -192,9 +194,11 @@ else { \ _mtx_lock_spin((mp), _tid, (opts), (file), (line)); \ } \ - } else \ + } else { \ lock_profile_obtain_lock_success(&(mp)->lock_object, 0, \ 0, (file), (line)); \ + LOCKSTAT_RECORD0(LS_MTX_SPIN_LOCK_ACQUIRE, mp); \ + } \ } while (0) #else /* SMP */ #define _get_spin_lock(mp, tid, opts, file, line) do { \ @@ -241,6 +245,7 @@ (mp)->mtx_recurse--; \ else { \ lock_profile_release_lock(&(mp)->lock_object); \ + LOCKSTAT_RECORD0(LS_MTX_SPIN_UNLOCK_RELEASE, mp); \ _release_lock_quick((mp)); \ } \ spinlock_exit(); \ ===================================================================== lockstat support --------------------------------------------------------------------- --- /u/freebsd/head/src/sys/sys/rwlock.h 2008-05-17 11:54:42.000000000 +1000 +++ /u/p4/dtrace/src/sys/sys/rwlock.h 2008-05-17 11:54:48.000000000 +1000 @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef _KERNEL #include @@ -107,9 +108,11 @@ \ if (!_rw_write_lock((rw), _tid)) \ _rw_wlock_hard((rw), _tid, (file), (line)); \ - else \ + else { \ lock_profile_obtain_lock_success(&(rw)->lock_object, 0, \ 0, (file), (line)); \ + LOCKSTAT_RECORD0(LS_RW_WLOCK_ACQUIRE, rw); \ + } \ } while (0) /* Release a write lock. */ ===================================================================== lockstat support --------------------------------------------------------------------- --- /u/freebsd/head/src/sys/sys/sx.h 2007-12-16 10:13:31.000000000 +1100 +++ /u/p4/dtrace/src/sys/sys/sx.h 2008-04-19 17:11:35.000000000 +1000 @@ -35,6 +35,7 @@ #include #include #include +#include #ifdef _KERNEL #include @@ -151,9 +152,11 @@ if (!atomic_cmpset_acq_ptr(&sx->sx_lock, SX_LOCK_UNLOCKED, tid)) error = _sx_xlock_hard(sx, tid, opts, file, line); - else + else { lock_profile_obtain_lock_success(&sx->lock_object, 0, 0, file, line); + LOCKSTAT_RECORD0(LS_SX_XLOCK_ACQUIRE, sx); + } return (error); } @@ -178,9 +181,11 @@ if (!(x & SX_LOCK_SHARED) || !atomic_cmpset_acq_ptr(&sx->sx_lock, x, x + SX_ONE_SHARER)) error = _sx_slock_hard(sx, opts, file, line); - else + else { lock_profile_obtain_lock_success(&sx->lock_object, 0, 0, file, line); + LOCKSTAT_RECORD0(LS_SX_SLOCK_ACQUIRE, sx); + } return (error); }