public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: 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, David Howells <dhowells@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: start_kernel(): bug: interrupts were enabled early
Date: Wed, 31 Mar 2010 14:28:21 -0700	[thread overview]
Message-ID: <20100331142821.425555e9.akpm@linux-foundation.org> (raw)
In-Reply-To: <4BB3BAD6.50308@zytor.com>

On Wed, 31 Mar 2010 14:12:54 -0700
"H. Peter Anvin" <hpa@zytor.com> wrote:

> On 03/31/2010 01:52 PM, Andrew Morton wrote:
> > On Wed, 31 Mar 2010 13:47:23 -0700
> > Yinghai Lu <yinghai@kernel.org> wrote:
> > 
> >> spin_unlock_irq from arm is different from other archs?
> > 
> > No, spin_unlock_irq() unconditionally enables interrupts on all
> > architectures.
> 
> So I found checkin 60ba96e546da45d9e22bb04b84971a25684e4d46 in the
> bk-historic git tree:
> 
> [PATCH] rwsem: Make rwsems use interrupt disabling spinlocks
> 
> The attached patch makes read/write semaphores use interrupt disabling
> spinlocks in the slow path, thus rendering the up functions and trylock
> functions available for use in interrupt context.  This matches the
> regular semaphore behaviour.
> 
> I've assumed that the normal down functions must be called with
> interrupts enabled (since they might schedule), and used the
> irq-disabling spinlock variants that don't save the flags.
> 
> Signed-Off-By: David Howells <dhowells@redhat.com>
> Tested-by: Badari Pulavarty <pbadari@us.ibm.com>
> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
> 
> What we have here is a case of this assumption being violated, because
> the lock is taken with interrupts disabled on a path where contention
> cannot happen (because the code is single-threaded at this point), but
> the lock is taken due to reuse of generic code.
> 
> The obvious way to fix this would be to use
> spin_lock_irqsave..spin_lock_irqrestore in __down_read as well as in the
> other locations; I don't have a good feel for what the cost of doing so
> would be, though.  On x86 it's fairly expensive simply because the only
> way to save the state is to push it on the stack, which the compiler
> doesn't deal well with, but this code isn't used on x86.
> 

Well, it's all a bit nasty.  kmem_cache_create() does a lot of stuff,
including calling into the page allocator with GFP_KERNEL - expecting
kmem_cache_create() to preserve local_irq_disable() is a bit optimistic.

radix_tree_init() calls hotcpu_notifier() which also does
mutex_lock(&cpu_add_remove_lock);

The easiest fix is to reposition the interrutps-are-now-enabled point
in start_kernel().  But I have a feeling that some versions of
early_irq_init() won't like that.

  reply	other threads:[~2010-03-31 21:29 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 [this message]
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
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=20100331142821.425555e9.akpm@linux-foundation.org \
    --to=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=torvalds@linux-foundation.org \
    --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