Date: Thu, 22 Nov 2007 16:40:51 +0100 From: Max Laier <max@love2party.net> To: freebsd-arch@freebsd.org Cc: attilio@freebsd.org, Stephan Uphoff <ups@freebsd.org>, Alfred Perlstein <alfred@freebsd.org> Subject: Re: rwlocks, correctness over speed. Message-ID: <200711221641.02484.max@love2party.net> In-Reply-To: <20071121222319.GX44563@elvis.mu.org> References: <20071121222319.GX44563@elvis.mu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--nextPart1509446.0MGOy2rOSm Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Wednesday 21 November 2007, Alfred Perlstein wrote: > In summary, I am proposing (temporarily) making read-recursion > on rwlocks not supported in order to avoid livelock due to writer > starvation. > > More details: > > We currently have a problem with our implementation of rwlocks. > > I think this is a key issue for 7.x as what we decide to support > will have rammifications for many years to come. > > We do not support writer priority or "fair share" usage of rwlocks > between readers and writers. > > We have several choices to rectify this. > > 1. Disallow recursion on rwlocks (witness can be used to enforce this), > this simplifies rwlocks such that we can avoid deadlock when a single > reader is trying to recurse while a writer is pending. > > 2. Track ownership of rwlocks, this can be implemented with a "rwlock > stack" in the per-thread control block (struct thread). Using this > ownership information we can determine if someone is recursing and > allow them to continue recursing despite a pending write request. > > I think the most simple solution currently is to drop support for > recursive reads on rwlocks until we have the facility in place > to properly support starvation avoidance. > > Why is this important? > > Simply put, developers that quickly "fix" some portion of code, > whether that be a driver or part of the kernel proper who use read > recursion will open the system to writer starvation and hence the > system will destabilize, particulary for high load situations. > > I would like to get this in before 7.0-RELEASE becasue otherwise > we're forced to implement something like the above mentioned solution > #2, which will degrade performance for most use cases of rwlocks. > > Comments? rwlocks are already used in places that do recursive reads. The one place= =20 I'm certain about is pfil(9) and we need a proper sollution for this. =20 Before rwlocks were used, I had a handrolled locking that supported both=20 read/write semantics and starvation avoidance - at the cost of failing to=20 allow futher read access when a writer asked for access. This however,=20 was quite application specific and not the most efficient implementation=20 either. If we were to disallow read recursion, we should have some generic lock=20 type that does allow it. rmlock(9)s seem to support full priority=20 propagation even for recursed readers. Can they be MFCed so that we have=20 an alternative? Are they considered ready for production? Should we=20 switch pfil(9) to them? It seems like a perfect match. Obviously rmlocks are not a general replacement for rwlocks, but in the=20 case of pfil they are the even better fit. =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 --nextPart1509446.0MGOy2rOSm 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) iD8DBQBHRaMOXyyEoT62BG0RAtQVAJ9smaoqoOsMT9pBENSunGrceFSNxgCfcOJu RtJGG6S6YmCYlXdxl7GyKcg= =68y9 -----END PGP SIGNATURE----- --nextPart1509446.0MGOy2rOSm--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711221641.02484.max>