From owner-freebsd-arch@FreeBSD.ORG Mon Oct 25 15:26:18 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from green.homeunix.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 007E216A4CF; Mon, 25 Oct 2004 15:26:18 +0000 (GMT) Received: from green.homeunix.org (green@localhost [127.0.0.1]) by green.homeunix.org (8.13.1/8.13.1) with ESMTP id i9PFQHvL085595; Mon, 25 Oct 2004 11:26:17 -0400 (EDT) (envelope-from green@green.homeunix.org) Received: (from green@localhost) by green.homeunix.org (8.13.1/8.13.1/Submit) id i9PFQGPu085594; Mon, 25 Oct 2004 11:26:16 -0400 (EDT) (envelope-from green) Date: Mon, 25 Oct 2004 11:26:15 -0400 From: Brian Fundakowski Feldman To: Sam Message-ID: <20041025152615.GQ1072@green.homeunix.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i cc: freebsd-current@freebsd.org cc: freebsd-arch@freebsd.org Subject: Re: 6.0 Witness squawk X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Oct 2004 15:26:18 -0000 On Mon, Oct 25, 2004 at 11:11:13AM -0500, Sam wrote: > Hello, > > I'm almost finished porting my AoE (ATA over Ethernet) > driver to 6.0 and have a question about a complaint witness > is making. > > In general, is it ok to sleep with a mutex held? > > Specifically, it works like this in the driver. > Each device struct has a mutex for guarding > operations on it. Discovering devices is a two > step process. First the device must respond to > an AoE Query command, then it must respond to > an ATA identify command. On the response to > the latter, I grab the device mutex, examine > the response and call disk_alloc() and disk_create(). > > Both of these functions call malloc with M_WAITOK, > the latter triggers the witness message. > > In my situation, I don't really mind if I sleep > with the mutex since I can't do any useful work > with the device anyway. > > This does leave the possibility that the netisr > for AoE could sleep. > > Thoughts? If you can't do any useful work, why do you have the mutex? Leave the mutex operations for when exclusivity _is_necessary_, after the major parts of initialization. No, it's not okay to sleep with a mutex held -- it must be dropped a la msleep/cv/whatever. -- Brian Fundakowski Feldman \'[ FreeBSD ]''''''''''\ <> green@FreeBSD.org \ The Power to Serve! \ Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\