From owner-p4-projects@FreeBSD.ORG Sat Jun 21 14:47:32 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8D02F1065681; Sat, 21 Jun 2008 14:47:32 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4E9B2106567C for ; Sat, 21 Jun 2008 14:47:32 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 413498FC17 for ; Sat, 21 Jun 2008 14:47:32 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m5LElWaL050217 for ; Sat, 21 Jun 2008 14:47:32 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m5LElWNW050215 for perforce@freebsd.org; Sat, 21 Jun 2008 14:47:32 GMT (envelope-from hselasky@FreeBSD.org) Date: Sat, 21 Jun 2008 14:47:32 GMT Message-Id: <200806211447.m5LElWNW050215@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 143881 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jun 2008 14:47:32 -0000 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);