From: Andrew Morton <akpm@zip.com.au>
To: Dave Hansen <haveblue@us.ibm.com>
Cc: Robert Love <rml@tech9.net>, Martin Wirth <Martin.Wirth@dlr.de>,
linux-kernel@vger.kernel.org, mingo@elte.hu, nigel@nrg.org
Subject: Re: [RFC] New locking primitive for 2.5
Date: Thu, 07 Feb 2002 12:06:22 -0800 [thread overview]
Message-ID: <3C62DE3E.DE15CAF2@zip.com.au> (raw)
In-Reply-To: <3C629F91.2869CB1F@dlr.de>, <3C629F91.2869CB1F@dlr.de> <1013107259.10430.29.camel@phantasy> <3C62D49A.4CBB6295@zip.com.au> <3C62DABA.3020906@us.ibm.com>
Dave Hansen wrote:
>
> Andrew Morton wrote:
> > Robert Love wrote:
> >>On Thu, 2002-02-07 at 10:38, Martin Wirth wrote:
> >>Some of the talk I've heard has been toward an adaptive lock. These are
> >>locks like Solaris's that can spin or sleep, usually depending on the
> >>state of the lock's holder. Another alternative, which I prefer since
> >>it is much less overhead, is a lock that spins-then-sleeps
> >>unconditionally.
> > I dunno. The spin-a-bit-then-sleep lock has always struck me as
> > i_dont_know_what_the_fuck_im_doing_lock(). Martin's approach puts
> > the decision in the hands of the programmer, rather than saying
> > "Oh gee I goofed" at runtime.
>
> The spin-then-sleep lock could be interesting as a replacement for the
> BKL in places where a semaphore causes performance degredation. In
> quite a few places where we replaced the BKL with a more finely grained
> semapore (not a spinlock because we needed to sleep during the hold),
> instead of spinning for a bit, it would schedule instead. This was bad
> :). Spin-then-sleep would be great behaviour in this situation.
But surely you *knew*, from inspection, which code paths needed
a spinning lock, and which code paths needed a sleeping lock?
Assuming the answer is "yes" then a nice fix would be to use
two separate locks - one which spins and one which sleeps.
Now, if the resource which is being protected truly cannot
be split up into spin-protected and sleep-protected sections
then a lock which can be atomically converted from spinning to
sleeping at the programmer's discretion seems appropriate.
A dynamic lock which says "we've spun for too long, let's sleep"
seems to be a tradeoff between programmer effort and efficiency,
and a bad one at that.
Possibly the locks could become more adaptive, and could, at
each call site, "learn" the expected spintime. But it all seems
too baroque to me.
-
next prev parent reply other threads:[~2002-02-07 20:07 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-07 15:38 [RFC] New locking primitive for 2.5 Martin Wirth
2002-02-07 18:04 ` Daniel Phillips
2002-02-07 18:06 ` Richard Gooch
2002-02-07 18:22 ` Christoph Hellwig
2002-02-07 19:33 ` Daniel Phillips
2002-02-07 19:55 ` Mark Frazer
2002-02-08 12:24 ` Denis Vlasenko
2002-02-07 18:40 ` Robert Love
2002-02-07 19:25 ` Andrew Morton
2002-02-07 19:51 ` Dave Hansen
2002-02-07 20:06 ` Andrew Morton [this message]
2002-02-07 20:11 ` Robert Love
2002-02-07 21:27 ` Ingo Molnar
2002-02-07 19:59 ` Andrew Morton
2002-02-08 8:20 ` Nigel Gamble
2002-02-08 17:06 ` Larry McVoy
2002-02-07 19:58 ` yodaiken
2002-02-07 20:08 ` Robert Love
2002-02-07 20:15 ` yodaiken
2002-02-07 20:20 ` Robert Love
2002-02-07 20:36 ` yodaiken
2002-02-07 20:57 ` Daniel Phillips
2002-02-07 21:00 ` yodaiken
2002-02-07 21:10 ` Daniel Phillips
2002-02-07 20:49 ` Martin Wirth
2002-02-08 8:34 ` Martin Wirth
2002-02-08 18:28 ` Linus Torvalds
2002-02-08 18:12 ` Martin Wirth
2002-02-08 18:33 ` Alexander Viro
2002-02-08 20:02 ` Linus Torvalds
2002-02-08 18:54 ` Andrew Morton
2002-02-08 19:11 ` Linus Torvalds
2002-02-08 19:21 ` Alexander Viro
2002-02-08 19:36 ` Robert Love
2002-02-09 0:18 ` Alexander Viro
2002-02-08 21:23 ` Ingo Molnar
2002-02-08 21:36 ` Linus Torvalds
2002-02-08 20:04 ` Jeff Garzik
2002-02-08 21:16 ` Mike Fedyk
2002-02-09 0:09 ` Alan Cox
2002-02-09 0:05 ` Mike Fedyk
2002-02-08 21:40 ` Benjamin Herrenschmidt
2002-02-09 19:32 ` Linus Torvalds
2002-02-07 19:56 ` yodaiken
2002-02-07 22:09 ` Ingo Molnar
2002-02-07 20:31 ` yodaiken
2002-02-07 20:57 ` Andrew Morton
2002-02-07 21:02 ` yodaiken
2002-02-08 12:31 ` Christoph Hellwig
2002-02-08 16:51 ` Nigel Gamble
2002-02-08 18:41 ` Andrew Morton
2002-02-08 20:47 ` Ingo Molnar
2002-02-08 18:56 ` Alexander Viro
2002-02-08 20:59 ` Ingo Molnar
2002-02-08 19:10 ` Alexander Viro
2002-02-08 20:14 ` Anton Altaparmakov
2002-02-08 20:38 ` yodaiken
2002-02-08 21:55 ` Anton Altaparmakov
2002-02-08 12:47 ` Denis Vlasenko
2002-02-08 15:13 ` yodaiken
2002-02-08 19:22 ` Horst von Brand
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=3C62DE3E.DE15CAF2@zip.com.au \
--to=akpm@zip.com.au \
--cc=Martin.Wirth@dlr.de \
--cc=haveblue@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=nigel@nrg.org \
--cc=rml@tech9.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox