From: Linus Torvalds <torvalds@linux-foundation.org>
To: David Howells <dhowells@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"H. Peter Anvin" <hpa@zytor.com>, Yinghai Lu <yinghai@kernel.org>,
Rabin Vincent <rabin@rab.in>, lkml <linux-kernel@vger.kernel.org>,
penberg@cs.helsinki.fi, cl@linux-foundation.org,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
linux-arch@vger.kernel.org
Subject: Re: start_kernel(): bug: interrupts were enabled early
Date: Fri, 2 Apr 2010 07:54:19 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.2.00.1004020748540.3634@i5.linux-foundation.org> (raw)
In-Reply-To: <28599.1270219574@redhat.com>
On Fri, 2 Apr 2010, David Howells wrote:
> Linus Torvalds <torvalds@linux-foundation.org> wrote:
>
> > Ahh, yes. In this case, that doesn't likely change anything. The
> > save/restore versions of the irq-safe locks shouldn't be appreciably more
> > expensive than the non-saving ones. And architectures that really care
> > should have done their own per-arch optimized version anyway.
>
> That depends on the CPU. Some CPUs have quite expensive interrupt disablement
> instructions. FRV does for instance; but fortunately, on the FRV, I can use
> some of the excessive quantities of conditional registers to pretend that I
> disable interrupts, and only actually do so if an interrupt actually happens.
I think you're missing the part where we're not _adding_ any irq disables:
we're just changing the unconditional irq disable to a save-and-disable
(and the unconditional irq enable to a restore).
So even if irq's are expensive to disable, the change from
spin_lock_irq()
to
spin_lock_irqsave()
won't make that code any more expensive.
> > Maybe we should even document that - so that nobody else makes the mistake
> > x86-64 did of thinking that the "generic spinlock" version of the rwsem's
> > is anything but a hacky and bad fallback case.
>
> In some cases, it's actually the best way. On a UP machine, for instance,
> where they reduce to nothing or where your only atomic instruction is an XCHG
> equivalent.
Again, you seem to think that we used to have just a plain spin_lock. Not
so. We currently have a spin_lock_irq(), and it is NOT a no-op even on UP.
It does that irq disable.
Anyway, I suspect that even with just an atomic xchg, you can do a better
job at doing down_read() than using the generic spin-lock version (likely
by busy-looping on a special "we're busy" value). But if you do want to
use the generic spin-lock version, I doubt any architecture makes that
irqsave version noticeable slower than the unconditional irq version.
Linus
next prev parent reply other threads:[~2010-04-02 15:00 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20100325194100.GA2364@debian>
2010-03-31 20:40 ` start_kernel(): bug: interrupts were enabled early Andrew Morton
2010-03-31 20:47 ` Yinghai Lu
2010-03-31 20:47 ` Yinghai Lu
2010-03-31 20:52 ` Andrew Morton
2010-03-31 21:12 ` H. Peter Anvin
2010-03-31 21:28 ` Andrew Morton
2010-03-31 22:35 ` Benjamin Herrenschmidt
2010-04-01 16:13 ` Linus Torvalds
2010-04-01 14:27 ` Andrew Morton
2010-04-01 20:12 ` Linus Torvalds
2010-04-02 14:46 ` David Howells
2010-04-02 14:54 ` Linus Torvalds [this message]
2010-04-07 19:09 ` Kevin Hilman
2010-04-08 15:55 ` Américo Wang
2010-04-08 15:55 ` Américo Wang
2010-03-31 21:01 ` Matthew Wilcox
2010-03-31 21:05 ` H. Peter Anvin
2010-03-31 21:17 ` Matthew Wilcox
2010-03-31 21:42 ` Christoph Lameter
2010-03-31 21:54 ` Russell King
2010-03-31 21:57 ` H. Peter Anvin
2010-03-31 21:57 ` H. Peter Anvin
2010-03-31 22:30 ` Russell King
2010-03-31 22:37 ` Benjamin Herrenschmidt
2010-03-31 22:49 ` Andrew Morton
2010-04-01 1:17 ` Benjamin Herrenschmidt
2010-03-31 22:26 ` Andrew Morton
2010-04-01 6:26 ` H. Peter Anvin
2010-04-01 3:33 ` Andrew Morton
2010-04-01 6:48 ` Benjamin Herrenschmidt
2010-04-01 11:06 ` David Howells
2010-04-01 15:55 ` Christoph Lameter
2010-04-01 23:00 ` Benjamin Herrenschmidt
2010-04-01 16:15 ` H. Peter Anvin
2010-04-01 16:15 ` H. Peter Anvin
2010-04-01 6:50 ` Benjamin Herrenschmidt
2010-03-31 22:36 ` Benjamin Herrenschmidt
2010-04-01 15:57 ` Christoph Lameter
2010-03-31 21:05 ` Russell King
2010-03-31 21:05 ` Russell King
2010-03-31 21:08 ` H. Peter Anvin
2010-03-31 21:08 ` H. Peter Anvin
2010-03-31 22:58 ` David Howells
2010-04-01 9:41 ` Jamie Lokier
2010-04-01 10:50 ` David Howells
2010-04-01 11:23 ` Matthew Wilcox
2010-03-31 22:31 ` Benjamin Herrenschmidt
2010-03-31 22:36 ` H. Peter Anvin
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=alpine.LFD.2.00.1004020748540.3634@i5.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=benh@kernel.crashing.org \
--cc=cl@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
--cc=rabin@rab.in \
--cc=yinghai@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