All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wirth <martin.wirth@epost.de>
To: unlisted-recipients:; (no To-header on input)@localhost.localdomain
Cc: Robert Love <rml@tech9.net>,
	linux-kernel@vger.kernel.org, akpm@zip.com.au, mingo@elte.hu
Subject: [RFC] New locking primitive for 2.5
Date: Thu, 07 Feb 2002 21:49:53 +0100	[thread overview]
Message-ID: <3C62E871.4514B926@epost.de> (raw)
In-Reply-To: <3C629F91.2869CB1F@dlr.de> <1013107259.10430.29.camel@phantasy>


Christoph Hellwig  wrote:
> I think this API is really ugly.  If both pathes actually do the same,
> just with different defaults, one lock function with a flag would be
> much nicer.  
Just to use plain numbers is not very instructive, so you ask for a
macro 
definition like COMBI_LOCK_SPIN_MODE ????? 


> Also why do we need two unlock functions?
There is the generic_unlock function, if you forgot in which mode you
are.
The main reason is performance for the spin mode: combi_spin_unlock is
just
a spin_unlock, no test, no branch. So you are faster if you know what
you did
a few lines of code before ;-)


Robert Love wrote:
> > If a spin_lock request is blocked by a mutex_lock call, the spin_lock
> > attempt also sleeps i.e. behaves like a semaphore.
> > If you gained ownership of the lock, you can switch between spin-mode
> > and mutex-(ie.e sleeping) mode by calling:
> 
> This can be bad.  What if I grab a spinlock in a codepath where only a
> spinlock is appropriate (i.e. somewhere I can't sleep, like an irq
> handler) -- and then I sleep?

As noted in my initial e-mail the current implementation is not for
use in irq-handlers or BHs etc. 
> 
> > Open questions:
> >
> >   * Does it make sense to also provide irq-save versions of the
> >     locking functions? This means you could use the unlock functions
> >     from interrupt context. But the main use in this situation is
> >     completion handling and there are already (new) completion handlers
> >     available. So I don't think this is a must have
> 
> You can't sleep in an interrupt request handler\x03, so this wouldn't make a
> lot of sense.

You of course were only allowed to call the unlock() functions!!
Therefore you could use them to free a resource from the handler
(but that's very much completion handling, see above).

> We shouldn't engage in wholesale changing of spinlocks to semaphores
> without a priority-inheritance mechanism.  And _that_ is the bigger
> issue ...

The combilock at least can be used to narrow the time windows for
priority
inversion because for most purposes you would use the spin mode. I
thinking
about some extension in this direction (that's why the owner field is a
pointer
to the owning task btw.).



> As for combi lock itself, it would be great, if it were possible to
> detect whether lock is held by thread running on the same CPU and sleep
> if so. This would allow for implementing interrupts as separate threads,
> etc.

That the e.g. the aproach of Solaris which results in about 5 time
higher 
latencies from a hardware interrupt to the waiting process.


    Martin Wirth

  parent reply	other threads:[~2002-02-07 20:51 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
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 [this message]
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=3C62E871.4514B926@epost.de \
    --to=martin.wirth@epost.de \
    --cc=akpm@zip.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.wirth@dlr.de \
    --cc=mingo@elte.hu \
    --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 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.