Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Feb 2008 23:02:13 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 135352 for review
Message-ID:  <200802132302.m1DN2D9d055694@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=135352

Change 135352 by jhb@jhb_mutex on 2008/02/13 23:01:15

	Add missing assertions and KTR logging to thread_lock().  This is
	why I wasn't getting assertion failures when thread_lock() recursed
	on a non-recursive spin mutex.

Affected files ...

.. //depot/projects/smpng/sys/kern/kern_mutex.c#151 edit

Differences ...

==== //depot/projects/smpng/sys/kern/kern_mutex.c#151 (text+ko) ====

@@ -498,7 +498,6 @@
 	int i, contested;
 	uint64_t waittime;
 
-	
 	contested = i = 0;
 	waittime = 0;
 	tid = (uintptr_t)curthread;
@@ -506,6 +505,15 @@
 retry:
 		spinlock_enter();
 		m = td->td_lock;
+		KASSERT(m->mtx_lock != MTX_DESTROYED,
+		    ("thread_lock() of destroyed mutex @ %s:%d", file, line));
+		KASSERT(LOCK_CLASS(&m->lock_object) == &lock_class_mtx_spin,
+		    ("thread_lock() of sleep mutex %s @ %s:%d",
+		    m->lock_object.lo_name, file, line));
+		if (mtx_owned(m))
+			KASSERT((m->lock_object.lo_flags & LO_RECURSABLE) != 0,
+	    ("thread_lock: recursed on non-recursive mutex %s @ %s:%d\n",
+			    m->lock_object.lo_name, file, line));
 		WITNESS_CHECKORDER(&m->lock_object,
 		    opts | LOP_NEWORDER | LOP_EXCLUSIVE, file, line);
 		while (!_obtain_lock(m, tid)) {
@@ -538,6 +546,8 @@
 	if (m->mtx_recurse == 0)
 		lock_profile_obtain_lock_success(&m->lock_object, contested,	
 		    waittime, (file), (line));
+	LOCK_LOG_LOCK("LOCK", &m->lock_object, opts, m->mtx_recurse, file,
+	    line);
 	WITNESS_LOCK(&m->lock_object, opts | LOP_EXCLUSIVE, file, line);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802132302.m1DN2D9d055694>