Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Apr 2002 08:35:24 -0800 (PST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 8891 for review
Message-ID:  <200204021635.g32GZOi51248@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://people.freebsd.org/~peter/p4db/chv.cgi?CH=8891

Change 8891 by jhb@jhb_laptop on 2002/04/02 08:35:07

	Integrate a few fixes from jhb_lock.

Affected files ...

... //depot/projects/smpng/sys/kern/subr_witness.c#36 integrate

Differences ...

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

@@ -477,6 +477,11 @@
 	td = curthread;
 
 	if (class->lc_flags & LC_SLEEPLOCK) {
+		/*
+		 * Since spin locks include a critical section, this check
+		 * impliclty enforces a lock order of all sleep locks before
+		 * all spin locks.
+		 */
 		if (td->td_critnest != 0 && (flags & LOP_TRYLOCK) == 0)
 			panic("blockable sleep lock (%s) %s @ %s:%d",
 			    class->lc_name, lock->lo_name, file, line);
@@ -593,7 +598,18 @@
 			if ((lock1->li_flags & LI_SLEPT) != 0 &&
 			    lock == &Giant.mtx_object)
 				continue;
-			if (!isitmydescendant(w, w1))
+			/*
+			 * If we are locking a sleepable lock and this lock
+			 * isn't sleepable and isn't Giant, we want to treat
+			 * it as a lock order violation to enfore a general
+			 * lock order of sleepable locks before non-sleepable
+			 * locks.  Thus, we only bother checking the lock
+			 * order hierarchy if we pass the initial test.
+			 */
+			if (!((lock->lo_flags & LO_SLEEPABLE) != 0 &&
+			    ((lock1->li_lock->lo_flags & LO_SLEEPABLE) == 0 &&
+			    lock1->li_lock != &Giant.mtx_object)) &&
+			    !isitmydescendant(w, w1))
 				continue;
 			/*
 			 * We have a lock order violation, check to see if it
@@ -827,10 +843,10 @@
 				    td->td_proc->p_pid,
 				    instance->li_lock->lo_name,
 				    (*lock_list)->ll_count - 1);
-				(*lock_list)->ll_count--;
-				for (j = i; j < (*lock_list)->ll_count; j++)
+				for (j = i; j < (*lock_list)->ll_count - 1; j++)
 					(*lock_list)->ll_children[j] =
 					    (*lock_list)->ll_children[j + 1];
+				(*lock_list)->ll_count--;
 				intr_restore(s);
 				if ((*lock_list)->ll_count == 0) {
 					lle = *lock_list;

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe p4-projects" in the body of the message




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