From owner-freebsd-arch@FreeBSD.ORG Wed Oct 13 21:02:01 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 75AAC16A4CE; Wed, 13 Oct 2004 21:02:01 +0000 (GMT) Received: from server1.astraldream.net (astraldream.net [69.20.5.160]) by mx1.FreeBSD.org (Postfix) with ESMTP id DFC4343D2D; Wed, 13 Oct 2004 21:02:00 +0000 (GMT) (envelope-from ssouhlal@FreeBSD.org) Received: from [192.168.1.12] (63-170-138-118.cst-sg.blacksburg.ntc-com.net [63.170.138.118]) (authenticated (0 bits)) by server1.astraldream.net (8.11.6/8.11.6) with ESMTP id i9DL1rX13719 (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits) verified NO); Wed, 13 Oct 2004 17:01:59 -0400 In-Reply-To: <200410111930.i9BJUODI068849@gw.catspoiler.org> References: <200410111930.i9BJUODI068849@gw.catspoiler.org> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <1C45EA64-1D5B-11D9-A525-000A95C4D7BC@FreeBSD.org> Content-Transfer-Encoding: 7bit From: Suleiman Souhlal Date: Wed, 13 Oct 2004 17:01:53 -0400 To: Don Lewis X-Mailer: Apple Mail (2.619) cc: freebsd-arch@FreeBSD.org Subject: Re: [RFC] sysctl locking 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: Wed, 13 Oct 2004 21:02:01 -0000 Hi, On Oct 11, 2004, at 3:30 PM, Don Lewis wrote: > There seems to be a lot of locking/unlocking overhead in the oid lookup > and oid tree manipulation code. Doing the traversals at each level of > the tree without holding a lock for the entire time makes me nervous, > though I can't point to any specific problem. It might be better to > just hold a single lock across then entire lookup, insertion, or > deletion operation. Thanks for your reply! I think you are right. It would also make the locking much simpler. However, there is the problem that sysctl handlers can sleep, so we shouldn't be holding a mutex when calling them.. > What happens if: > thread A owns an oid > > thread B, which wants to delete the oid, goes to sleep to wait > for the oid > > thread C wants the oid and goes to sleep > > thread A releases the oid and wakes up thread B > > thread B deletes the oid > > thread C does ??? I didn't think of this possibility. I guess I'll have to rethink the whole thing, whenever I find some time. -- Suleiman Souhlal | ssouhlal@vt.edu The FreeBSD Project | ssouhlal@FreeBSD.org