Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jun 2008 14:47:32 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 143881 for review
Message-ID:  <200806211447.m5LElWNW050215@repoman.freebsd.org>

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

Change 143881 by hselasky@hselasky_laptop001 on 2008/06/21 14:47:07

	
	Fix a problem with Giant and condition variables.
	Please see the diff for an explanation.
	
	Maybe someone into locking can review this patch?

Affected files ...

.. //depot/projects/usb/src/sys/kern/kern_mutex.c#9 edit

Differences ...

==== //depot/projects/usb/src/sys/kern/kern_mutex.c#9 (text+ko) ====

@@ -133,7 +133,8 @@
 void
 lock_mtx(struct lock_object *lock, int how)
 {
-
+	if (how == 1)
+		return;
 	mtx_lock((struct mtx *)lock);
 }
 
@@ -150,6 +151,18 @@
 	struct mtx *m;
 
 	m = (struct mtx *)lock;
+	if ((m == &Giant) && (!mtx_owned(m))) {
+		/* 
+		 * Sometimes DROP_GIANT() gets in our way when we use
+		 * the system condition variables passing the "Giant"
+		 * mutex. If Giant is not locked when we get into this
+		 * function then we can simply ignore those cases,
+		 * because the locking is then handled by the DROP_XXX
+		 * macros!
+		 */
+		return (1);
+	}
+
 	mtx_assert(m, MA_OWNED | MA_NOTRECURSED);
 	mtx_unlock(m);
 	return (0);



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