Commit 2ce802f62ba32a7d95748ac92bf351f76affb6ff

Authored by Tejun Heo
Committed by Ingo Molnar
1 parent 12fcdba1b7

lockdep: Move early boot local IRQ enable/disable status to init/main.c

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.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Pekka Enberg <penberg@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
LKML-Reference: <20110120110635.GB6036@htj.dyndns.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 6 changed files with 15 additions and 36 deletions Side-by-side Diff

arch/x86/xen/enlighten.c
... ... @@ -1194,7 +1194,7 @@
1194 1194 per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];
1195 1195  
1196 1196 local_irq_disable();
1197   - early_boot_irqs_off();
  1197 + early_boot_irqs_disabled = true;
1198 1198  
1199 1199 memblock_init();
1200 1200  
include/linux/kernel.h
... ... @@ -243,6 +243,8 @@
243 243 extern unsigned long get_taint(void);
244 244 extern int root_mountflags;
245 245  
  246 +extern bool early_boot_irqs_disabled;
  247 +
246 248 /* Values used for system_state */
247 249 extern enum system_states {
248 250 SYSTEM_BOOTING,
include/linux/lockdep.h
... ... @@ -436,16 +436,8 @@
436 436 #endif /* CONFIG_LOCKDEP */
437 437  
438 438 #ifdef CONFIG_TRACE_IRQFLAGS
439   -extern void early_boot_irqs_off(void);
440   -extern void early_boot_irqs_on(void);
441 439 extern void print_irqtrace_events(struct task_struct *curr);
442 440 #else
443   -static inline void early_boot_irqs_off(void)
444   -{
445   -}
446   -static inline void early_boot_irqs_on(void)
447   -{
448   -}
449 441 static inline void print_irqtrace_events(struct task_struct *curr)
450 442 {
451 443 }
... ... @@ -96,6 +96,15 @@
96 96 extern void tc_init(void);
97 97 #endif
98 98  
  99 +/*
  100 + * Debug helper: via this flag we know that we are in 'early bootup code'
  101 + * where only the boot processor is running with IRQ disabled. This means
  102 + * two things - IRQ must not be enabled before the flag is cleared and some
  103 + * operations which are not allowed with IRQ disabled are allowed while the
  104 + * flag is set.
  105 + */
  106 +bool early_boot_irqs_disabled __read_mostly;
  107 +
99 108 enum system_states system_state __read_mostly;
100 109 EXPORT_SYMBOL(system_state);
101 110  
... ... @@ -554,7 +563,7 @@
554 563 cgroup_init_early();
555 564  
556 565 local_irq_disable();
557   - early_boot_irqs_off();
  566 + early_boot_irqs_disabled = true;
558 567  
559 568 /*
560 569 * Interrupts are still disabled. Do necessary setups, then
... ... @@ -621,7 +630,7 @@
621 630 if (!irqs_disabled())
622 631 printk(KERN_CRIT "start_kernel(): bug: interrupts were "
623 632 "enabled early\n");
624   - early_boot_irqs_on();
  633 + early_boot_irqs_disabled = false;
625 634 local_irq_enable();
626 635  
627 636 /* Interrupts are enabled now so all GFP allocations are safe. */
... ... @@ -2292,22 +2292,6 @@
2292 2292 }
2293 2293  
2294 2294 /*
2295   - * Debugging helper: via this flag we know that we are in
2296   - * 'early bootup code', and will warn about any invalid irqs-on event:
2297   - */
2298   -static int early_boot_irqs_enabled;
2299   -
2300   -void early_boot_irqs_off(void)
2301   -{
2302   - early_boot_irqs_enabled = 0;
2303   -}
2304   -
2305   -void early_boot_irqs_on(void)
2306   -{
2307   - early_boot_irqs_enabled = 1;
2308   -}
2309   -
2310   -/*
2311 2295 * Hardirqs will be enabled:
2312 2296 */
2313 2297 void trace_hardirqs_on_caller(unsigned long ip)
... ... @@ -2319,7 +2303,7 @@
2319 2303 if (unlikely(!debug_locks || current->lockdep_recursion))
2320 2304 return;
2321 2305  
2322   - if (DEBUG_LOCKS_WARN_ON(unlikely(!early_boot_irqs_enabled)))
  2306 + if (DEBUG_LOCKS_WARN_ON(unlikely(early_boot_irqs_disabled)))
2323 2307 return;
2324 2308  
2325 2309 if (unlikely(curr->hardirqs_enabled)) {
kernel/trace/trace_irqsoff.c
... ... @@ -453,14 +453,6 @@
453 453 * Stubs:
454 454 */
455 455  
456   -void early_boot_irqs_off(void)
457   -{
458   -}
459   -
460   -void early_boot_irqs_on(void)
461   -{
462   -}
463   -
464 456 void trace_softirqs_on(unsigned long ip)
465 457 {
466 458 }