All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pekka Enberg <penberg@cs.helsinki.fi>
Subject: [PATCH UPDATED 1/2] lockdep: move early boot local IRQ enable/disable status to init/main.c
Date: Thu, 20 Jan 2011 13:20:25 +0100	[thread overview]
Message-ID: <20110120122025.GG6036@htj.dyndns.org> (raw)
In-Reply-To: <20110120120001.GA32671@elte.hu>

During early boot, local IRQ is disabled until IRQ subsystem is
properly initialized.  During this time, no one should enable local
IRQ and some operations which usually are not allowed with IRQ
disabled, e.g. operations which might sleep or require communications
with other processors, are allowed.

lockdep tracked this with early_boot_irqs_off/on() callbacks.  As
other subsystems need this information too, move it to init/main.c and
make it generally available.  While at it, toggle the boolean to
early_boot_irqs_disabled instead of enabled so that it can be
initialized with %false and %true indicates the exceptional condition.

* The original patch missed conversions of several users causing build
  failures.  Updated.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>
---
On Thu, Jan 20, 2011 at 01:00:01PM +0100, Ingo Molnar wrote:
> I'll be able to do more testing and see whether the bug is really
> fixed once the modular kernel build failure is fixed.

Sorry about that.  Here's the updated patch.  The second one doesn't
need to be changed.

Thanks.

 arch/x86/xen/enlighten.c     |    2 +-
 include/linux/kernel.h       |    2 ++
 include/linux/lockdep.h      |    8 --------
 init/main.c                  |   13 +++++++++++--
 kernel/lockdep.c             |   18 +-----------------
 kernel/trace/trace_irqsoff.c |    8 --------
 6 files changed, 15 insertions(+), 36 deletions(-)

Index: work/include/linux/kernel.h
===================================================================
--- work.orig/include/linux/kernel.h
+++ work/include/linux/kernel.h
@@ -243,6 +243,8 @@ extern int test_taint(unsigned flag);
 extern unsigned long get_taint(void);
 extern int root_mountflags;
 
+extern bool early_boot_irqs_disabled;
+
 /* Values used for system_state */
 extern enum system_states {
 	SYSTEM_BOOTING,
Index: work/init/main.c
===================================================================
--- work.orig/init/main.c
+++ work/init/main.c
@@ -96,6 +96,15 @@ static inline void mark_rodata_ro(void)
 extern void tc_init(void);
 #endif
 
+/*
+ * Debug helper: via this flag we know that we are in 'early bootup code'
+ * where only the boot processor is running with IRQ disabled.  This means
+ * two things - IRQ must not be enabled before the flag is cleared and some
+ * operations which are not allowed with IRQ disabled are allowed while the
+ * flag is set.
+ */
+bool early_boot_irqs_disabled __read_mostly;
+
 enum system_states system_state __read_mostly;
 EXPORT_SYMBOL(system_state);
 
@@ -554,7 +563,7 @@ asmlinkage void __init start_kernel(void
 	cgroup_init_early();
 
 	local_irq_disable();
-	early_boot_irqs_off();
+	early_boot_irqs_disabled = true;
 
 /*
  * Interrupts are still disabled. Do necessary setups, then
@@ -621,7 +630,7 @@ asmlinkage void __init start_kernel(void
 	if (!irqs_disabled())
 		printk(KERN_CRIT "start_kernel(): bug: interrupts were "
 				 "enabled early\n");
-	early_boot_irqs_on();
+	early_boot_irqs_disabled = false;
 	local_irq_enable();
 
 	/* Interrupts are enabled now so all GFP allocations are safe. */
Index: work/kernel/lockdep.c
===================================================================
--- work.orig/kernel/lockdep.c
+++ work/kernel/lockdep.c
@@ -2292,22 +2292,6 @@ mark_held_locks(struct task_struct *curr
 }
 
 /*
- * Debugging helper: via this flag we know that we are in
- * 'early bootup code', and will warn about any invalid irqs-on event:
- */
-static int early_boot_irqs_enabled;
-
-void early_boot_irqs_off(void)
-{
-	early_boot_irqs_enabled = 0;
-}
-
-void early_boot_irqs_on(void)
-{
-	early_boot_irqs_enabled = 1;
-}
-
-/*
  * Hardirqs will be enabled:
  */
 void trace_hardirqs_on_caller(unsigned long ip)
@@ -2319,7 +2303,7 @@ void trace_hardirqs_on_caller(unsigned l
 	if (unlikely(!debug_locks || current->lockdep_recursion))
 		return;
 
-	if (DEBUG_LOCKS_WARN_ON(unlikely(!early_boot_irqs_enabled)))
+	if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled)))
 		return;
 
 	if (unlikely(curr->hardirqs_enabled)) {
Index: work/arch/x86/xen/enlighten.c
===================================================================
--- work.orig/arch/x86/xen/enlighten.c
+++ work/arch/x86/xen/enlighten.c
@@ -1194,7 +1194,7 @@ asmlinkage void __init xen_start_kernel(
 	per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
 
 	local_irq_disable();
-	early_boot_irqs_off();
+	early_boot_irqs_disabled = true;
 
 	memblock_init();
 
Index: work/include/linux/lockdep.h
===================================================================
--- work.orig/include/linux/lockdep.h
+++ work/include/linux/lockdep.h
@@ -436,16 +436,8 @@ do {								\
 #endif /* CONFIG_LOCKDEP */
 
 #ifdef CONFIG_TRACE_IRQFLAGS
-extern void early_boot_irqs_off(void);
-extern void early_boot_irqs_on(void);
 extern void print_irqtrace_events(struct task_struct *curr);
 #else
-static inline void early_boot_irqs_off(void)
-{
-}
-static inline void early_boot_irqs_on(void)
-{
-}
 static inline void print_irqtrace_events(struct task_struct *curr)
 {
 }
Index: work/kernel/trace/trace_irqsoff.c
===================================================================
--- work.orig/kernel/trace/trace_irqsoff.c
+++ work/kernel/trace/trace_irqsoff.c
@@ -453,14 +453,6 @@ void time_hardirqs_off(unsigned long a0,
  * Stubs:
  */
 
-void early_boot_irqs_off(void)
-{
-}
-
-void early_boot_irqs_on(void)
-{
-}
-
 void trace_softirqs_on(unsigned long ip)
 {
 }


  reply	other threads:[~2011-01-20 12:20 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-18 23:54 Linux 2.6.38-rc1 Linus Torvalds
2011-01-19  2:07 ` Linus Torvalds
2011-01-19  3:42   ` Justin Mattock
2011-01-19  3:53     ` Linus Torvalds
2011-01-19  4:05       ` Justin Mattock
2011-01-19  5:10       ` nobody
2011-01-19  5:42         ` Linus Torvalds
2011-01-19  5:56           ` Linus Torvalds
2011-01-19 18:07             ` Steven Rostedt
2011-01-19 18:26               ` Linus Torvalds
2011-01-21  3:23           ` tag&track [Re: Linux 2.6.38-rc1] nobody
2011-01-21  8:24             ` Alexey Dobriyan
2011-01-23  8:13   ` Linux 2.6.38-rc1 Török Edwin
2011-01-19  7:39 ` Linux 2.6.38-rc1 doesn't boot Markus Trippelsdorf
2011-01-19  7:46   ` Shaohua Li
2011-01-19  7:55     ` Markus Trippelsdorf
2011-01-19  7:49   ` Markus Trippelsdorf
2011-01-19  8:12     ` Shaohua Li
2011-01-19  8:56       ` H. Peter Anvin
2011-01-19  9:09         ` Ingo Molnar
2011-01-20  2:08           ` Shaohua Li
2011-01-20  3:32             ` Lu, Hongjiu
2011-01-20 11:25             ` Ingo Molnar
2011-01-20 15:08               ` Anvin, H Peter
2011-01-21  7:18                 ` Shaohua Li
2011-01-21  7:55                   ` Shaohua Li
2011-01-21 15:28                   ` H. Peter Anvin
2011-01-21 15:37                     ` Lu, Hongjiu
2011-01-21 21:09                       ` Ingo Molnar
2011-01-19  9:33         ` [tip:x86/urgent] Revert "x86: Make relocatable kernel work with new binutils" tip-bot for Ingo Molnar
2011-01-20  4:59     ` Linux 2.6.38-rc1 doesn't boot Alexandre Courbot
2011-01-19  8:39 ` PPS parport boot lockup: INFO: HARDIRQ-READ-safe -> HARDIRQ-READ-unsafe lock order detected Ingo Molnar
2011-01-20 13:04   ` Alexander Gordeev
2011-01-21 14:44   ` Alexander Gordeev
2011-01-21 16:37     ` Linus Torvalds
2011-01-21 19:43       ` Ingo Molnar
2011-01-24 23:28         ` Alexander Gordeev
2011-01-24 23:46         ` [PATCH] pps: claim parallel port exclusively Alexander Gordeev
2011-01-25  0:19           ` Ingo Molnar
2011-01-24 15:00       ` PPS parport boot lockup: INFO: HARDIRQ-READ-safe -> HARDIRQ-READ-unsafe lock order detected Alexander Gordeev
2011-01-24 15:12   ` [PATCH] parport: make lockdep happy with waitlist_lock Alexander Gordeev
2011-01-24 15:28     ` Ingo Molnar
2011-01-24 15:33       ` Alexander Gordeev
2011-01-19 12:02 ` percpu related boot crash on x86 (was: Linux 2.6.38-rc1) Ingo Molnar
2011-01-19 12:44   ` Tejun Heo
2011-01-19 12:48   ` Peter Zijlstra
2011-01-19 12:56     ` Pekka Enberg
2011-01-19 13:12       ` Peter Zijlstra
2011-01-19 13:13       ` Tejun Heo
2011-01-19 20:53         ` Ingo Molnar
2011-01-19 23:11           ` Ingo Molnar
2011-01-20  8:31             ` percpu related boot crash on x86 Pekka Enberg
2011-01-20 10:47               ` Peter Zijlstra
2011-01-20 11:12                 ` Eric Dumazet
2011-01-20 11:19                   ` Tejun Heo
2011-01-20 11:06   ` [PATCH 1/2] lockdep: move early boot local IRQ enable/disable status to init/main.c Tejun Heo
2011-01-20 11:07     ` [PATCH 2/2] smp: allow on_each_cpu() to be called while early_boot_irqs_disabled " Tejun Heo
2011-01-20 20:22       ` [tip:core/urgent] smp: Allow " tip-bot for Tejun Heo
2011-01-20 11:11     ` [PATCH 1/2] lockdep: move early boot local IRQ enable/disable " Tejun Heo
2011-01-20 11:23       ` Peter Zijlstra
2011-01-20 11:26         ` Tejun Heo
2011-01-20 11:30           ` Pekka Enberg
2011-01-20 11:38           ` Peter Zijlstra
2011-01-20 12:00       ` Ingo Molnar
2011-01-20 12:20         ` Tejun Heo [this message]
2011-01-20 11:51     ` Ingo Molnar
2011-01-20 20:21     ` [tip:core/urgent] lockdep: Move " tip-bot for Tejun Heo
2011-01-19 21:40 ` Linux 2.6.38-rc1 Alan Cox
2011-01-21 15:30   ` Aaro Koskinen

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=20110120122025.GG6036@htj.dyndns.org \
    --to=tj@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 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.