Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Aug 2006 13:42:15 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        Suleiman Souhlal <ssouhlal@freebsd.org>
Cc:        Attilio Rao <attilio@freebsd.org>, freebsd-current@freebsd.org, freebsd-arch@freebsd.org
Subject:   Re: [PATCH] Adding Solaris-style "owner of records" to rwlocks
Message-ID:  <200608081342.15839.jhb@freebsd.org>
In-Reply-To: <44D7B7ED.5070302@FreeBSD.org>
References:  <3bbf2fe10608071227j17c4cfa6qd84e1d8e53668fda@mail.gmail.com> <44D7B7ED.5070302@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 07 August 2006 18:00, Suleiman Souhlal wrote:
> Attilio Rao wrote:
> > This is a first implementation of the owner of records concept in rwlocks.
> > It allows to avoid the priority inversion problem in the current
> > rwlocks implementation (for readers).
> > 
> > The main idea (that John and I discussed) is to have as owner of
> > records the first rlock'er for a "class contention".
> > The implementation consists in adding two flags (RW_LOCK_OWNED and
> > RW_LOCK_EXEMPTED) which are used in order to not penalyze the easy
> > case, and syncronizing the operation of acquiring and dropping the
> > owner of records with the turnstile spin-lock.
> > The main scheme might work in this way:
> > 
> > thread1::rlock() -> sets the owner of records
> > thread2::rlock() -> checks for RW_LOCK_OWNED bit and, if it is set, go
> > in the easy case
> > thread3::rlock() -> checks for RW_LOCK_OWNED...
> > thread4::wlock() -> blocks and land its priority to thread1
> > thread1::runlock() -> disable the owner of records (disowning the
> > associated turnstile) and sets the RW_LOCK_EXEMPTED flag. In this way
> > other threads will treact as an easy case.
> > ...
> 
> Aren't you missing the hard part: transferring ownership from one reader 
> to another? If you don't, you'll still have priority inversions as soon 
> as the initial reader unlocks..

Even Solaris doesn't do this as the overhead to do this would seem to outweigh 
the advantages of having a perfect implementation.  I think Attilio is 
actually going to try it several different ways and then run benchmarks to 
see if that assertion is true.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608081342.15839.jhb>