All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <juergen.gross@fujitsu-siemens.com>
To: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: xen-devel@lists.xensource.com, Keir Fraser <keir.fraser@eu.citrix.com>
Subject: Re: spinlock requests (was RE: [Patch] don't spin with irq disabled)
Date: Mon, 30 Mar 2009 08:11:43 +0200	[thread overview]
Message-ID: <49D0629F.5020708@fujitsu-siemens.com> (raw)
In-Reply-To: <1b224859-9faa-47fc-82ed-6207ae2574cc@default>

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@fujitsu-siemens.com
Otto-Hahn-Ring 6                Internet: www.fujitsu-siemens.com
D-81739 Muenchen         Company details: www.fujitsu-siemens.com/imprint.html

  parent reply	other threads:[~2009-03-30  6:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-26  9:00 [Patch] don't spin with irq disabled Juergen Gross
2009-03-26 12:23 ` Jan Beulich
2009-03-26 12:36   ` Juergen Gross
2009-03-27  7:41     ` Jan Beulich
2009-03-27  9:09       ` Keir Fraser
2009-03-27 17:00         ` spinlock requests (was RE: [Patch] don't spin with irq disabled) Dan Magenheimer
2009-03-27 17:46           ` Keir Fraser
2009-03-27 18:00             ` Dan Magenheimer
2009-03-27 18:12               ` Keir Fraser
2009-04-02 23:08                 ` Dan Magenheimer
2009-04-03  7:17                   ` Keir Fraser
2009-03-30  6:11           ` Juergen Gross [this message]
2009-03-31 13:12             ` Dan Magenheimer
2009-03-31 13:40               ` Juergen Gross
2009-03-31 13:48                 ` Keir Fraser
2009-03-31 19:00                   ` Jeremy Fitzhardinge
2009-03-31 20:57                     ` Keir Fraser
2009-03-31 21:16                       ` Jeremy Fitzhardinge
2009-03-26 14:27 ` [Patch] don't spin with irq disabled Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49D0629F.5020708@fujitsu-siemens.com \
    --to=juergen.gross@fujitsu-siemens.com \
    --cc=dan.magenheimer@oracle.com \
    --cc=keir.fraser@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.