Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Sep 2005 17:43:48 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 82969 for review
Message-ID:  <200509011743.j81HhmeS042603@repoman.freebsd.org>

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

Change 82969 by jhb@jhb_slimer on 2005/09/01 17:43:10

	If Giant is acquired while another mutex is held, force a LOR since
	Giant must always come before other mutexes.

Affected files ...

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

Differences ...

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

@@ -259,9 +259,15 @@
 static struct lock_list_entry w_locklistdata[LOCK_CHILDCOUNT];
 
 static struct witness_order_list_entry order_lists[] = {
+	/*
+	 * sx locks
+	 */
 	{ "proctree", &lock_class_sx },
 	{ "allproc", &lock_class_sx },
 	{ NULL, NULL },
+	/*
+	 * Various mutexes
+	 */
 	{ "Giant", &lock_class_mtx_sleep },
 	{ "filedesc structure", &lock_class_mtx_sleep },
 	{ "pipe mutex", &lock_class_mtx_sleep },
@@ -869,13 +875,22 @@
 			 * order violation to enfore a general lock order of
 			 * sleepable locks before non-sleepable locks.
 			 */
-			if (!((lock->lo_flags & LO_SLEEPABLE) != 0 &&
+			if (((lock->lo_flags & LO_SLEEPABLE) != 0 &&
 			    (lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0))
-			    /*
-			     * Check the lock order hierarchy for a reveresal.
-			     */
-			    if (!isitmydescendant(w, w1))
+				goto reversal;
+			/*
+			 * If we are locking Giant and this is a non-sleepable
+			 * lock, then treat it as a reversal.
+			 */
+			if ((lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0 &&
+			    lock == &Giant.mtx_object)
+				goto reversal;
+			/*
+			 * Check the lock order hierarchy for a reveresal.
+			 */
+			if (!isitmydescendant(w, w1))
 				continue;
+		reversal:
 			/*
 			 * We have a lock order violation, check to see if it
 			 * is allowed or has already been yelled about.



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