From owner-freebsd-current@FreeBSD.ORG Thu Sep 30 18:58:05 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1554416A4CE; Thu, 30 Sep 2004 18:58:05 +0000 (GMT) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 68A0343D39; Thu, 30 Sep 2004 18:58:04 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.13.1/8.13.1) with ESMTP id i8UIvvr4048734; Thu, 30 Sep 2004 20:58:02 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: John Baldwin From: "Poul-Henning Kamp" In-Reply-To: Your message of "Thu, 30 Sep 2004 14:09:25 EDT." <200409301409.25904.jhb@FreeBSD.org> Date: Thu, 30 Sep 2004 20:57:57 +0200 Message-ID: <48733.1096570677@critter.freebsd.dk> Sender: phk@critter.freebsd.dk cc: freebsd-current@FreeBSD.org cc: current@FreeBSD.org Subject: Re: Unit number allocation API X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Sep 2004 18:58:05 -0000 In message <200409301409.25904.jhb@FreeBSD.org>, John Baldwin writes: >On Thursday 30 September 2004 03:06 am, Poul-Henning Kamp wrote: >> I had this one out on arch@ previously. I'm very interested in informed >> feedback on how we deal with locking for service api's like this. > >I would suggest that the caller should ask for a unit before it needs a lock >and if it finds that it doesn't need the unit after all it can give it back >in the error handling. That is, this is similar to malloc'ing a structure up >front, then grabbing locks and making changes, then after releasing the lock >free'ing the structure if it turned out we didn't need it. Right. My personal guess is that driver->attach() and driver->probe() will never get out from Giant (I can't seriously see the benefits as being bigger than the effort) and therefore I think the problem of locking API's like this can be wholesale ignored for a very long time. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.