From owner-cvs-all@FreeBSD.ORG Fri Jan 16 14:33:17 2004 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 399DF16A4CE for ; Fri, 16 Jan 2004 14:33:17 -0800 (PST) Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9086843D45 for ; Fri, 16 Jan 2004 14:33:09 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 15339 invoked from network); 16 Jan 2004 22:33:09 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 16 Jan 2004 22:33:09 -0000 Received: from 10.50.40.206 (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.10/8.12.10) with ESMTP id i0GMX4M0089506; Fri, 16 Jan 2004 17:33:04 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=), src-committers@FreeBSD.org Date: Fri, 16 Jan 2004 17:07:09 -0500 User-Agent: KMail/1.5.4 References: <200401162154.i0GLsuKq056578@repoman.freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200401161707.09423.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) cc: cvs-src@FreeBSD.org cc: cvs-all@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_descrip.c X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jan 2004 22:33:17 -0000 On Friday 16 January 2004 04:57 pm, Dag-Erling Sm=F8rgrav wrote: > Dag-Erling Smorgrav writes: > > WITNESS won't let us hold two filedesc locks at the same time, so > > juggle fdp and newfdp around a bit. > > The question though is, is there a real reason why we can't hold two > filedesc locks at the same time, or is WITNESS being unnecessarily > pedantic? In this case you are safe because one lock doesn't even need to be held at= =20 all. However, in the normal case this is a very valid check. It is only=20 safe to acquire two locks of the same type if you have a well-defined order= =20 in the way that you lock multiple locks. For example, for proc locks, when= =20 we do acquire them multiple times we either 1) use mtx_trylock() (which can= 't=20 block, so it's not a problem) or 2) we lock the child process first and the= =20 parent process second. If you just arbitrarily lock two of the same type o= f=20 lock then you can get a deadlock if two different threads are trying to loc= k=20 the two same locks in reverse order. This can happen if you forget to unlo= ck=20 a lock also for example. It is best to let WITNESS catch as many errors as= =20 possible rather than just shutting them up for one special case that you=20 don't wish to work around. Esp. if that one case is locking something that= =20 doesn't even need to be locked. :-) =2D-=20 John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =3D http://www.FreeBSD.org