From owner-freebsd-arch@FreeBSD.ORG Thu Aug 12 05:57:20 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DC2DB16A4CE for ; Thu, 12 Aug 2004 05:57:19 +0000 (GMT) Received: from mail3.speakeasy.net (mail3.speakeasy.net [216.254.0.203]) by mx1.FreeBSD.org (Postfix) with ESMTP id B1E6F43D54 for ; Thu, 12 Aug 2004 05:57:17 +0000 (GMT) (envelope-from jmg@hydrogen.funkthat.com) Received: (qmail 7565 invoked from network); 12 Aug 2004 05:57:13 -0000 Received: from gate.funkthat.com (HELO hydrogen.funkthat.com) ([69.17.45.168]) (envelope-sender ) by mail3.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 12 Aug 2004 05:57:13 -0000 Received: from hydrogen.funkthat.com (fybura@localhost.funkthat.com [127.0.0.1])i7C5vDuU016190; Wed, 11 Aug 2004 22:57:13 -0700 (PDT) (envelope-from jmg@hydrogen.funkthat.com) Received: (from jmg@localhost) by hydrogen.funkthat.com (8.12.10/8.12.10/Submit) id i7C5vC4l016189; Wed, 11 Aug 2004 22:57:12 -0700 (PDT) Date: Wed, 11 Aug 2004 22:57:12 -0700 From: John-Mark Gurney To: John Baldwin Message-ID: <20040812055712.GC991@funkthat.com> Mail-Followup-To: John Baldwin , freebsd-arch@FreeBSD.org References: <20040806224316.GB991@funkthat.com> <200408091026.35755.jhb@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200408091026.35755.jhb@FreeBSD.org> User-Agent: Mutt/1.4.1i X-Operating-System: FreeBSD 4.2-RELEASE i386 X-PGP-Fingerprint: B7 EC EF F8 AE ED A7 31 96 7A 22 B3 D8 56 36 F4 X-Files: The truth is out there X-URL: http://resnet.uoregon.edu/~gurney_j/ X-Resume: http://resnet.uoregon.edu/~gurney_j/resume.html cc: freebsd-arch@FreeBSD.org Subject: Re: valid dup lock logic for witness X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: John-Mark Gurney List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2004 05:57:20 -0000 John Baldwin wrote this message on Mon, Aug 09, 2004 at 10:26 -0400: > On Friday 06 August 2004 06:43 pm, John-Mark Gurney wrote: > > I have been working on kqueue, and to support kq in kq, I need to obtain > > two kq locks (both of the same type) at the same time. Normally this can > > cause a deadlock, but using a proper lock ordering strategy, it can be > > avoided. In the kq case, I chose to aquire a kq global lock before > > acquiring multiple kq locks. (In the proc case, jhb said you aquire > > the child's before the parents.) > > > > Mutexs have the flag MTX_DUPOK that notify witness that duplicate locks > > are ok, but this can hide other problems (and in fact would have in my > > testing). > > > > I have created a patch that lets you inform witness the a duplicate lock > > is valid as long as you hold another lock. The only run time change is > > that when a duplicate lock is found, it will run through another table > > to verify it's ok before printing out the back trace. > > > > Anyone have objections to this? > > As I said on IRC, my objection to this is that there are numerous ways of > acquiring duplicate locks in a valid fashion. For kq there is a global lock > around such cases. For proc locks child processes are locked before parents. > The problem is that there is not a single way of doing this, so if you want > WITNESS to check all of these, you will have to add lots of special case > one-off hacks to WITNESS making it even more obtuse and slow. Perhaps > something that might be feasible is to provide some sort of way for other > parts of the kernel to register a duplicate check function for a given lock > type. This would let you keep the code doing the duplicate check closer to > the code using the locks for one thing and would avoid adding N hacks to > witness for the various different dup lock checks. How about that, but making the dup lock ok w/ a signle parent lock a generic function. I would imagine there are a finite number of ways to solve duplicate locks, and they will end up being shared between different subsystems. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not."