WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: spinlock requests (was RE: [Xen-devel] [Patch] don't spin with irq d

To: Dan Magenheimer <dan.magenheimer@xxxxxxxxxx>
Subject: Re: spinlock requests (was RE: [Xen-devel] [Patch] don't spin with irq disabled)
From: Juergen Gross <juergen.gross@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 30 Mar 2009 08:11:43 +0200
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Sun, 29 Mar 2009 23:12:09 -0700
Domainkey-signature: s=s768; d=fujitsu-siemens.com; c=nofws; q=dns; h=X-SBRSScore:X-IronPort-AV:Received:X-IronPort-AV: Received:Received:Message-ID:Date:From:Organization: User-Agent:MIME-Version:To:CC:Subject:References: In-Reply-To:X-Enigmail-Version:Content-Type: Content-Transfer-Encoding; b=sRsZpdaCgkjCPZqGihAAuAQSiP5lMwuOxfxN9oMW7+XkACDzH0IlVSTk BWSzBy9vO+TlckXv23cHUga5/5GMH7+IrOry1PiJLkNmO4T62X+aHOwlR 5v43av2qCJWAAKe;
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1b224859-9faa-47fc-82ed-6207ae2574cc@default>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Fujitsu Siemens Computers
References: <1b224859-9faa-47fc-82ed-6207ae2574cc@default>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103)
Dan Magenheimer wrote:
> Keir (and/or others) --
> 
> If you are messing around in the spinlock code anyway,
> I have a couple of requests.  Tmem needs:
> 
> rw_is_write_locked(rwlock_t *lock)
> 
> and
> 
> write_trylock(rwlock_t *lock)
> 
> I implemented the latter by grabbing the C code from Linux
> and it seems to work, but it would be nice if it was
> consistent with the other lock code in xen and
> my asm statement understanding is too poor to try.
> 
> For rw_is_write_locked(), I had a devil of a time
> because of what appeared to be a weird code generated
> race; the obvious simple implementation failed
> periodically... apparently due to racing against
> try_readlock attempts!  (I use it in an ASSERT so it
> was a rather noticeable and spectacular failure!)
> The workaround I used below is a horrible hack
> but I haven't had problems since.
> 
> Thanks,
> Dan

Dan,

if you are planning to use rw_locks you should be aware that the current
implementation in Xen is sub-optimal on systems with high processor counts.
Read locks always succeed when other readers are already holding the lock,
even if a writer is waiting for the lock. If there are many potential readers
they might (in theory) lock out a writer for rather long times.
A better solution would be to stop further readers to acquire the lock if a
writer is waiting for it.

Juergen

-- 
Juergen Gross                             Principal Developer
IP SW OS6                      Telephone: +49 (0) 89 636 47950
Fujitsu Siemens Computers         e-mail: juergen.gross@xxxxxxxxxxxxxxxxxxx
Otto-Hahn-Ring 6                Internet: www.fujitsu-siemens.com
D-81739 Muenchen         Company details: www.fujitsu-siemens.com/imprint.html

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>