From owner-freebsd-current@FreeBSD.ORG Mon Dec 13 22:03:40 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 F11B916A50C for ; Mon, 13 Dec 2004 22:03:39 +0000 (GMT) Received: from server1.astraldream.net (astraldream.net [69.20.5.160]) by mx1.FreeBSD.org (Postfix) with ESMTP id D12B843D5A for ; Mon, 13 Dec 2004 22:03:36 +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 iBDM3UQ24915 (using TLSv1/SSLv3 with cipher RC4-SHA (128 bits) verified NO); Mon, 13 Dec 2004 17:03:36 -0500 In-Reply-To: <200412130913.20215.max@love2party.net> References: <94AE3F5A-4CD6-11D9-8BD6-000A95C4D7BC@FreeBSD.org> <200412130913.20215.max@love2party.net> Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Suleiman Souhlal Date: Mon, 13 Dec 2004 17:03:29 -0500 To: Max Laier X-Mailer: Apple Mail (2.619) cc: freebsd-current@FreeBSD.org Subject: Re: sysctl locking 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: Mon, 13 Dec 2004 22:03:40 -0000 Hi, On Dec 13, 2004, at 3:13 AM, Max Laier wrote: > You have identified two places where Giant is explicitly asserted, but > I am > afraid that there are much more handlers that don't assert Giant but > need it. > Moreover, the "simple" handler might also write to memory that is > implicitly > protected by Giant and should not be modified without it. Right. > As a transition step I suggest that we extend the API in the way the > callout > API works. So that you can ask for a Giant-free handler call by > setting an > MPSAFE flag. > > On a side note, I am not sure if I like the string copy thing - while I > understand the intention. Neither am I sure if it is a good idea to > introduce > "yet another sleep lock/reference count thingy"[tm] before sitting > down and > giving some attention to the existing sx(9) implementation. I haven't > fully > read/understand your ref-count there, hence I can not tell if sx(9) > will > really work - and I know (very well) that sx(9) isn't the optimal > answer > sometimes (most of the time). But I am suggesting that we give that a > closer > look before reinventing the wheel over and over again. Oh, and last but > *definitely* least, your patch could use some style(9) facelifting. > e.g. tab > after #define. The patch at http://people.freebsd.org/~ssouhlal/sysctl-sx-locking.diff fixes most of your concerns. It unconditionally acquires Giant just before calling the handler, but I'm hoping that we'll find another solution. It also uses sx(9), and requires the following patch to be applied: http://people.freebsd.org/~ssouhlal/sx_xlocked.diff . The latter creates a new function, int sx_xlocked(struct sx *sx), that returns non-zero when the exclusive lock is held by the current thread, and zero otherwise. Bye. -- Suleiman Souhlal | ssouhlal@vt.edu The FreeBSD Project | ssouhlal@FreeBSD.org