From: Oliver Neukum <oliver@neukum.org>
To: Andrey Borzenkov <arvidjaar@mail.ru>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: when spin_lock_irq (as opposed to spin_lock_irqsave) is appropriate?
Date: Sun, 12 Oct 2008 10:08:50 +0200 [thread overview]
Message-ID: <200810121008.50657.oliver@neukum.org> (raw)
In-Reply-To: <200810111955.14667.arvidjaar@mail.ru>
Am Samstag, 11. Oktober 2008 17:55:13 schrieb Andrey Borzenkov:
> On Saturday 11 October 2008, Oliver Neukum wrote:
> > Am Samstag, 11. Oktober 2008 17:29:01 schrieb Andrey Borzenkov:
> > > Logically, one piece of kernel code has no way to know whether another
> > > piece of kernel code (or may be hard-/firmware) has disabled some
> > > interrupt line. So it looks like spin_lock_irq should not even exist,
> > > except may be for very specific cases (where we are sure no other piece
> > > of kernel code may run concurrently)?
> > >
> > > Sorry for stupid question, I an not actually a HW type of person ...
> > >
> >
> > This has no connection with individual irq lines. It's about being able
> > to sleep. Kernel code usually knows whether it can sleep.
> > If it knows to be able to sleep it can use spin_lock_irq() which is
> > more efficient than spin_lock_irqsave()
> >
>
> Sorry? I can't sleep under spinlock ... *any* spinlock? Or has this changed?
You cannot sleep under spinlock.
> May I be I was not clear with question. spin_lock_irq implies spin_unlock_irq,
> which unconditionally enables interrupts. But I have no idea which interrupts
> were disabled before spin_lock_irq; so I may accidentally enable too much?
>
> Or what exactly "irq" in spin_(un-)lock_irq means?
I think I see the source of the problem. The interrupt controller is not
involved. The interrupts are masked in the cpu. This mask switches off
all interrupts (save nmi). When you unmask them again all interrupts
the interrupt controllers allow are active again. This is perfectly safe.
HTH
Oliver
next prev parent reply other threads:[~2008-10-12 8:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-11 15:29 when spin_lock_irq (as opposed to spin_lock_irqsave) is appropriate? Andrey Borzenkov
2008-10-11 15:41 ` Oliver Neukum
2008-10-11 15:55 ` Andrey Borzenkov
2008-10-12 8:08 ` Oliver Neukum [this message]
2008-10-11 16:18 ` Arjan van de Ven
2008-10-12 11:48 ` Andrey Borzenkov
2008-10-12 22:21 ` Arnd Bergmann
2008-10-12 23:12 ` Arjan van de Ven
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=200810121008.50657.oliver@neukum.org \
--to=oliver@neukum.org \
--cc=arvidjaar@mail.ru \
--cc=linux-kernel@vger.kernel.org \
/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