Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Dec 2005 20:05:59 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 88898 for review
Message-ID:  <200512292005.jBTK5xIf073608@repoman.freebsd.org>

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

Change 88898 by jhb@jhb_slimer on 2005/12/29 20:05:30

	You can't call printf while holding the witness mutex or you can
	trigger a deadlock (which I've reproduced several times today ;-P)
	with the spin locks used in console drivers.  Fix the one printf
	I recently added which had this bug.

Affected files ...

.. //depot/projects/smpng/sys/kern/subr_witness.c#145 edit

Differences ...

==== //depot/projects/smpng/sys/kern/subr_witness.c#145 (text+ko) ====

@@ -1409,18 +1409,8 @@
 			return (w);
 		}
 	}
-	/*
-	 * We issue a warning for any spin locks not defined in the static
-	 * order list as a way to discourage their use (folks should really
-	 * be using non-spin mutexes most of the time).  However, several
-	 * 3rd part device drivers use spin locks because that is all they
-	 * have available on Windows and Linux and they think that normal
-	 * mutexes are insufficient.
-	 */
-	if ((lock_class->lc_flags & LC_SPINLOCK) && witness_spin_warn)
-		printf("WITNESS: spin lock %s not in order list", description);
 	if ((w = witness_get()) == NULL)
-		return (NULL);
+		goto out;
 	w->w_name = description;
 	w->w_class = lock_class;
 	w->w_refcount = 1;
@@ -1437,6 +1427,17 @@
 		    lock_class->lc_name);
 	}
 	mtx_unlock_spin(&w_mtx);
+out:
+	/*
+	 * We issue a warning for any spin locks not defined in the static
+	 * order list as a way to discourage their use (folks should really
+	 * be using non-spin mutexes most of the time).  However, several
+	 * 3rd part device drivers use spin locks because that is all they
+	 * have available on Windows and Linux and they think that normal
+	 * mutexes are insufficient.
+	 */
+	if ((lock_class->lc_flags & LC_SPINLOCK) && witness_spin_warn)
+		printf("WITNESS: spin lock %s not in order list", description);
 	return (w);
 }
 
@@ -1988,7 +1989,7 @@
 		FOREACH_THREAD_IN_PROC(p, td) {
 			if (!witness_thread_has_locks(td))
 				continue;
-			printf("Process %d (%s) thread %p (%d)\n", p->p_pid,
+			db_printf("Process %d (%s) thread %p (%d)\n", p->p_pid,
 			    p->p_comm, td, td->td_tid);
 			witness_list(td);
 		}



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