From owner-freebsd-arch@FreeBSD.ORG Thu Nov 22 16:26:45 2007 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 156A316A418; Thu, 22 Nov 2007 16:26:45 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.179]) by mx1.freebsd.org (Postfix) with ESMTP id 8145413C458; Thu, 22 Nov 2007 16:26:44 +0000 (UTC) (envelope-from max@love2party.net) Received: from amd64.laiers.local (dslb-088-066-042-157.pools.arcor-ip.net [88.66.42.157]) by mrelayeu.kundenserver.de (node=mrelayeu2) with ESMTP (Nemesis) id 0MKwtQ-1IvEsR0LTV-0001MF; Thu, 22 Nov 2007 17:26:37 +0100 From: Max Laier Organization: FreeBSD To: "Attilio Rao" Date: Thu, 22 Nov 2007 17:26:18 +0100 User-Agent: KMail/1.9.7 References: <20071121222319.GX44563@elvis.mu.org> <200711221641.02484.max@love2party.net> <3bbf2fe10711220753u435ff4cbxa94d5b682292b970@mail.gmail.com> In-Reply-To: <3bbf2fe10711220753u435ff4cbxa94d5b682292b970@mail.gmail.com> X-Face: ,,8R(x[kmU]tKN@>gtH1yQE4aslGdu+2]; R]*pL,U>^H?)gW@49@wdJ`H<=?utf-8?q?=25=7D*=5FBD=0A=09U=5For=3D=5CmOZf764=26nYj=3DJYbR1PW0ud?=>|!~,,CPC.1-D$FG@0h3#'5"k{V]a~.<=?utf-8?q?mZ=7D44=23Se=7Em=0A=09Fe=7E=5C=5DX5B=5D=5Fxj?=(ykz9QKMw_l0C2AQ]}Ym8)fU MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart3738284.cOpIyjHv6B"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200711221726.27108.max@love2party.net> X-Provags-ID: V01U2FsdGVkX1/33zApj4Rn60gPfuH+f30VOP1Jwqtc1NNzDqY UcaHGyrvHnfNcmxjK+836DaOQynRJIfMA02kN9rz9ZbLlzWJKr rGsWUTN0Mv614ba1OF2tyWKCxTjbjlS/9wMUt5Bv7o= Cc: Stephan Uphoff , Alfred Perlstein , freebsd-arch@freebsd.org Subject: Re: rwlocks, correctness over speed. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2007 16:26:45 -0000 --nextPart3738284.cOpIyjHv6B Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Thursday 22 November 2007, Attilio Rao wrote: > 2007/11/22, Max Laier : > > rwlocks are already used in places that do recursive reads. The one > > place I'm certain about is pfil(9) and we need a proper sollution for > > this. Before rwlocks were used, I had a handrolled locking that > > supported both read/write semantics and starvation avoidance - at the > > cost of failing to allow futher read access when a writer asked for > > access. This however, was quite application specific and not the > > most efficient implementation either. > > I'm not a pfil(9) expert, but for what I've heard, rmlocks should be > really good for it, shouldn't them? > > The concept is that if we want to maintain fast paths for rwlock we > cannot do too much tricks there. And you can really deadlock if you > allow recursion on readers... How about adding rwlock_try_rlock() which would do the following: 1) Only variant to allow[1] read recursion and ... 2) ... only if no outstanding write requests 3) Let the caller deal with failure This can be implemented statically, so no overhead in the fast path. The=20 caller is in the best position to decide if it is recursing or not -=20 could keep that info on the stack - and can either fail[2] or do a normal=20 rwlock_rlock() which would wait for the writer to enter and exit. [2] In most situation where you use read locks you can fail or roll back=20 carefully as you didn't change anything - obviously. In pfil - for=20 instance - we just dropped the packet if there was a writer waiting. [1] "allow" in terms of WITNESS - if that can be done. > > If we were to disallow read recursion, we should have some generic > > lock type that does allow it. rmlock(9)s seem to support full > > priority propagation even for recursed readers. Can they be MFCed so > > that we have an alternative? Are they considered ready for > > production? Should we switch pfil(9) to them? It seems like a > > perfect match. > > I've not looked over rmlocks so much, but as they track readers they > can do priority propagation (if it is not implemented, it could be > done -- not sure about the cost of the operation though). > > Attilio =2D-=20 /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News --nextPart3738284.cOpIyjHv6B Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (FreeBSD) iD8DBQBHRa2zXyyEoT62BG0RAkc+AJ98NfsoXSxOL8tDhTm9bCBuUi/QhACcDnd9 vPh6R30xaq+pPREBtb5BE1w= =IlV/ -----END PGP SIGNATURE----- --nextPart3738284.cOpIyjHv6B--