From owner-freebsd-doc@FreeBSD.ORG Wed Dec 29 18:34:17 2004 Return-Path: Delivered-To: freebsd-doc@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0139416A528 for ; Wed, 29 Dec 2004 18:34:16 +0000 (GMT) Received: from mail1.speakeasy.net (mail1.speakeasy.net [216.254.0.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E0FB43D5A for ; Wed, 29 Dec 2004 18:34:16 +0000 (GMT) (envelope-from jhb@FreeBSD.org) Received: (qmail 29950 invoked from network); 29 Dec 2004 18:34:16 -0000 Received: from dsl027-160-063.atl1.dsl.speakeasy.net (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) encrypted SMTP for ; 29 Dec 2004 18:34:15 -0000 Received: from [10.50.41.243] (gw1.twc.weather.com [216.133.140.1]) (authenticated bits=0) by server.baldwin.cx (8.12.11/8.12.11) with ESMTP id iBTIY00B003706; Wed, 29 Dec 2004 13:34:11 -0500 (EST) (envelope-from jhb@FreeBSD.org) From: John Baldwin To: freebsd-doc@FreeBSD.org, Giorgos Keramidas Date: Wed, 29 Dec 2004 13:34:17 -0500 User-Agent: KMail/1.6.2 References: <200412290840.iBT8eQuf017631@freefall.freebsd.org> In-Reply-To: <200412290840.iBT8eQuf017631@freefall.freebsd.org> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200412291334.17967.jhb@FreeBSD.org> X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on server.baldwin.cx Subject: Re: docs/75571: man page for sx(9) is misleading X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Dec 2004 18:34:18 -0000 On Wednesday 29 December 2004 03:40 am, Giorgos Keramidas wrote: > The following reply was made to PR docs/75571; it has been noted by GNATS. > > From: Giorgos Keramidas > To: bug-followup@freebsd.org > Cc: > Subject: Re: docs/75571: man page for sx(9) is misleading > Date: Wed, 29 Dec 2004 10:37:13 +0200 > > On 2004-12-28 13:55, Darren Reed wrote: > > According to discussion on freebsd mailing lists, it is not possible > > to hold an sx lock when you want a mtx lock. This should be documented. > > As far as I can tell, by looking at kern_sx.c and sys/sx.h, this is > because the sx lock initialization uses an mtxpool for the mutex used to > serialize access to the internal sx lock data. > > Leaf locks may be used in operations that msleep() but there can be only > one of them in each lock path and no other lock can be obtained after > them. > > This is sort of implied by the SEE ALSO reference of mtx_pool(9), but we > should probably state it explicitly in CONTEXT. The reason is largely because they can be held across a sleep, e.g.: sx_xlock(&foo->sx); bar = malloc(sizeof(*bar), M_FOO, M_WAITOK); TAILQ_INSERT_TAIL(&foo->head, bar, link); sx_xunlock(&foo->sx); This is intentional and that is what should be documented. Basically, it needs a paragraph to the effect of: .Pp An .Nm lock may not be acquired while holding a mutex. Since threads are allowed to sleep while holding an .NM lock, a thread that acquired a mutex and then blocked on an .Nm lock would end up sleeping while holding a mutex which is not allowed. > %%% > Index: sx.9 > =================================================================== > RCS file: /home/ncvs/src/share/man/man9/sx.9,v > retrieving revision 1.29 > diff -u -r1.29 sx.9 > --- sx.9 11 Jul 2004 16:08:25 -0000 1.29 > +++ sx.9 28 Dec 2004 23:28:22 -0000 > @@ -196,6 +196,11 @@ > A thread may hold a shared or exclusive lock on an > .Nm > lock while sleeping. > +The > +.Nm > +locks are implemented using > +.Xr mtxpool 9 > +shared leaf locks, so they should always be the last lock obtained. > .Sh SEE ALSO > .Xr condvar 9 , > .Xr mtx_pool 9 , > %%% > _______________________________________________ > freebsd-doc@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-doc > To unsubscribe, send any mail to "freebsd-doc-unsubscribe@freebsd.org" -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org