--- /usr/src/sys/kern/kern_mutex.c	Sun Mar 11 05:43:23 2007
+++ kern_mutex.c	Wed Mar 21 04:50:58 2007
@@ -188,8 +188,8 @@
 	    file, line);
 
 	_get_sleep_lock(m, curthread, opts, file, line);
-	LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file,
-	    line);
+	LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_object.lo_recurse,
+	    file, line);
 	WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
 	curthread->td_locks++;
 }
@@ -205,8 +205,8 @@
 	    file, line));
 	curthread->td_locks--;
 	WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
-	LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file,
-	    line);
+	LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_object.lo_recurse,
+	    file, line);
 	mtx_assert(m, MA_OWNED);
 
 	lock_profile_release_lock(&m->mtx_object);
@@ -226,8 +226,8 @@
 	WITNESS_CHECKORDER(&m->mtx_object, opts | LOP_NEWORDER | LOP_EXCLUSIVE,
 	    file, line);
 	_get_spin_lock(m, curthread, opts, file, line);
-	LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file,
-	    line);
+	LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_object.lo_recurse,
+	    file, line);
 	WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
 }
 
@@ -242,8 +242,8 @@
 	    ("mtx_unlock_spin() of sleep mutex %s @ %s:%d",
 	    m->mtx_object.lo_name, file, line));
 	WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line);
-	LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file,
-	    line);
+	LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_object.lo_recurse,
+	    file, line);
 	mtx_assert(m, MA_OWNED);
 
 	lock_profile_release_lock(&m->mtx_object);
@@ -269,7 +269,7 @@
 	    file, line));
 
 	if (mtx_owned(m) && (m->mtx_object.lo_flags & LO_RECURSABLE) != 0) {
-		m->mtx_recurse++;
+		m->mtx_object.lo_recurse++;
 		atomic_set_ptr(&m->mtx_lock, MTX_RECURSED);
 		rval = 1;
 	} else
@@ -280,7 +280,7 @@
 		WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE | LOP_TRYLOCK,
 		    file, line);
 		curthread->td_locks++;
-		if (m->mtx_recurse == 0)
+		if (m->mtx_object.lo_recurse == 0)
 			lock_profile_obtain_lock_success(&m->mtx_object, contested,
 			    waittime, file, line);
 
@@ -311,7 +311,7 @@
 		KASSERT((m->mtx_object.lo_flags & LO_RECURSABLE) != 0,
 	    ("_mtx_lock_sleep: recursed on non-recursive mutex %s @ %s:%d\n",
 		    m->mtx_object.lo_name, file, line));
-		m->mtx_recurse++;
+		m->mtx_object.lo_recurse++;
 		atomic_set_ptr(&m->mtx_lock, MTX_RECURSED);
 		if (LOCK_LOG_TEST(&m->mtx_object, opts))
 			CTR1(KTR_LOCK, "_mtx_lock_sleep: %p recursing", m);
@@ -486,7 +486,7 @@
 #endif
 
 	if (mtx_recursed(m)) {
-		if (--(m->mtx_recurse) == 0)
+		if (--(m->mtx_object.lo_recurse) == 0)
 			atomic_clear_ptr(&m->mtx_lock, MTX_RECURSED);
 		if (LOCK_LOG_TEST(&m->mtx_object, opts))
 			CTR1(KTR_LOCK, "_mtx_unlock_sleep: %p unrecurse", m);
@@ -695,7 +695,6 @@
 
 	/* Initialize mutex. */
 	m->mtx_lock = MTX_UNOWNED;
-	m->mtx_recurse = 0;
 
 	lock_profile_object_init(&m->mtx_object, class, name);
 	lock_init(&m->mtx_object, class, name, type, flags);
@@ -791,7 +790,7 @@
 		db_printf(" owner: %p (tid %d, pid %d, \"%s\")\n", td,
 		    td->td_tid, td->td_proc->p_pid, td->td_proc->p_comm);
 		if (mtx_recursed(m))
-			db_printf(" recursed: %d\n", m->mtx_recurse);
+			db_printf(" recursed: %d\n", m->mtx_object.lo_recurse);
 	}
 }
 #endif
--- /usr/src/sys/kern/subr_lock.c	Sun Mar  4 10:17:59 2007
+++ subr_lock.c	Wed Mar 21 06:01:51 2007
@@ -196,11 +196,13 @@
     const char *type, int flags)
 {
 	int i;
+	const char *tptr;
 
 	/* Check for double-init and zero object. */
 	KASSERT(!lock_initalized(lock), ("lock \"%s\" %p already initialized",
 	    name, lock));
 
+	tptr = type != NULL ? type : name;
 	/* Look up lock class to find its index. */
 	for (i = 0; i < LOCK_CLASS_MAX; i++)
 		if (lock_classes[i] == class) {
@@ -211,8 +213,11 @@
 
 	/* Initialize the lock object. */
 	lock->lo_name = name;
-	lock->lo_type = type != NULL ? type : name;
+#ifdef WITNESS
+	lock->lo_type = tptr;
+#endif
 	lock->lo_flags |= flags | LO_INITIALIZED;
+	lock->lo_recurse = 0;
 	LOCK_LOG_INIT(lock, 0);
 	WITNESS_INIT(lock);
 }
@@ -222,6 +227,7 @@
 {
 
 	KASSERT(lock_initalized(lock), ("lock %p is not initialized", lock));
+	KASSERT(lock->lo_recurse == 0, ("lock %p is recursed yet", lock));
 	WITNESS_DESTROY(lock);
 	LOCK_LOG_DESTROY(lock, 0);
 	lock->lo_flags &= ~LO_INITIALIZED;
@@ -243,8 +249,10 @@
 	class = LOCK_CLASS(lock);
 	db_printf(" class: %s\n", class->lc_name);
 	db_printf(" name: %s\n", lock->lo_name);
+#ifdef WITNESS
 	if (lock->lo_type && lock->lo_type != lock->lo_name)
 		db_printf(" type: %s\n", lock->lo_type);
+#endif
 	class->lc_ddb_show(lock);
 }
 #endif
--- /usr/src/sys/sys/_lock.h	Wed Nov 29 19:21:25 2006
+++ _lock.h	Wed Mar 21 04:41:42 2007
@@ -55,15 +55,18 @@
 
 struct lock_object {
 	const	char *lo_name;		/* Individual lock name. */
-	const	char *lo_type;		/* General lock type. */
-	u_int	lo_flags;
+	uint16_t lo_flags;
+	uint16_t lo_recurse;
 #ifdef LOCK_PROFILING
         struct  lock_profile_object lo_profile_obj;
 #endif
+#ifdef WITNESS
+	const	char *lo_type;		/* General lock type. */
 	union {				/* Data for witness. */
 		STAILQ_ENTRY(lock_object) lod_list;
 		struct	witness *lod_witness;
 	} lo_witness_data;
+#endif
 };
 
 #endif /* !_SYS__LOCK_H_ */
--- /usr/src/sys/sys/_mutex.h	Wed Nov 29 19:21:25 2006
+++ _mutex.h	Wed Mar 21 04:41:55 2007
@@ -37,7 +37,6 @@
 struct mtx {
 	struct lock_object	mtx_object;	/* Common lock properties. */
 	volatile uintptr_t	mtx_lock;	/* Owner and flags. */
-	volatile u_int		mtx_recurse;	/* Number of recursive holds. */
 };
 
 #endif /* !_SYS__MUTEX_H_ */
--- /usr/src/sys/sys/mutex.h	Sun Mar 11 05:43:24 2007
+++ mutex.h	Wed Mar 21 04:47:47 2007
@@ -184,7 +184,7 @@
 	spinlock_enter();						\
 	if (!_obtain_lock((mp), _tid)) {				\
 		if ((mp)->mtx_lock == _tid)				\
-			(mp)->mtx_recurse++;				\
+			(mp)->mtx_object.lo_recurse++;			\
 		else {							\
 			lock_profile_obtain_lock_failed(&(mp)->mtx_object, \
 			    &contested, &waittime);			\
@@ -200,7 +200,7 @@
 									\
 	spinlock_enter();						\
 	if ((mp)->mtx_lock == _tid)					\
-		(mp)->mtx_recurse++;					\
+		(mp)->mtx_object.lo_recurse++;					\
 	else {								\
 		KASSERT((mp)->mtx_lock == MTX_UNOWNED, ("corrupt spinlock")); \
 		(mp)->mtx_lock = _tid;				\
@@ -236,7 +236,7 @@
 #ifdef SMP
 #define _rel_spin_lock(mp) do {						\
 	if (mtx_recursed((mp)))						\
-		(mp)->mtx_recurse--;					\
+		(mp)->mtx_object.lo_recurse--;				\
 	else								\
 		_release_lock_quick((mp));				\
 	spinlock_exit();						\
@@ -244,7 +244,7 @@
 #else /* SMP */
 #define _rel_spin_lock(mp) do {						\
 	if (mtx_recursed((mp)))						\
-		(mp)->mtx_recurse--;					\
+		(mp)->mtx_object.lo_recurse--;				\
 	else								\
 		(mp)->mtx_lock = MTX_UNOWNED;				\
 	spinlock_exit();						\
@@ -346,7 +346,7 @@
 
 #define mtx_owned(m)	(((m)->mtx_lock & ~MTX_FLAGMASK) == (uintptr_t)curthread)
 
-#define mtx_recursed(m)	((m)->mtx_recurse != 0)
+#define mtx_recursed(m)	((m)->mtx_object.lo_recurse != 0)
 
 #define mtx_name(m)	((m)->mtx_object.lo_name)
 
