aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c85
1 files changed, 61 insertions, 24 deletions
diff --git a/init/main.c b/init/main.c
index d721dad05dd7..2c5ade79eb81 100644
--- a/init/main.c
+++ b/init/main.c
@@ -24,6 +24,7 @@
24#include <linux/smp_lock.h> 24#include <linux/smp_lock.h>
25#include <linux/initrd.h> 25#include <linux/initrd.h>
26#include <linux/bootmem.h> 26#include <linux/bootmem.h>
27#include <linux/acpi.h>
27#include <linux/tty.h> 28#include <linux/tty.h>
28#include <linux/gfp.h> 29#include <linux/gfp.h>
29#include <linux/percpu.h> 30#include <linux/percpu.h>
@@ -56,6 +57,7 @@
56#include <linux/debug_locks.h> 57#include <linux/debug_locks.h>
57#include <linux/debugobjects.h> 58#include <linux/debugobjects.h>
58#include <linux/lockdep.h> 59#include <linux/lockdep.h>
60#include <linux/kmemleak.h>
59#include <linux/pid_namespace.h> 61#include <linux/pid_namespace.h>
60#include <linux/device.h> 62#include <linux/device.h>
61#include <linux/kthread.h> 63#include <linux/kthread.h>
@@ -64,6 +66,8 @@
64#include <linux/idr.h> 66#include <linux/idr.h>
65#include <linux/ftrace.h> 67#include <linux/ftrace.h>
66#include <linux/async.h> 68#include <linux/async.h>
69#include <linux/kmemcheck.h>
70#include <linux/kmemtrace.h>
67#include <trace/boot.h> 71#include <trace/boot.h>
68 72
69#include <asm/io.h> 73#include <asm/io.h>
@@ -71,7 +75,6 @@
71#include <asm/setup.h> 75#include <asm/setup.h>
72#include <asm/sections.h> 76#include <asm/sections.h>
73#include <asm/cacheflush.h> 77#include <asm/cacheflush.h>
74#include <trace/kmemtrace.h>
75 78
76#ifdef CONFIG_X86_LOCAL_APIC 79#ifdef CONFIG_X86_LOCAL_APIC
77#include <asm/smp.h> 80#include <asm/smp.h>
@@ -86,11 +89,6 @@ extern void sbus_init(void);
86extern void prio_tree_init(void); 89extern void prio_tree_init(void);
87extern void radix_tree_init(void); 90extern void radix_tree_init(void);
88extern void free_initmem(void); 91extern void free_initmem(void);
89#ifdef CONFIG_ACPI
90extern void acpi_early_init(void);
91#else
92static inline void acpi_early_init(void) { }
93#endif
94#ifndef CONFIG_DEBUG_RODATA 92#ifndef CONFIG_DEBUG_RODATA
95static inline void mark_rodata_ro(void) { } 93static inline void mark_rodata_ro(void) { }
96#endif 94#endif
@@ -533,6 +531,22 @@ void __init __weak thread_info_cache_init(void)
533{ 531{
534} 532}
535 533
534/*
535 * Set up kernel memory allocators
536 */
537static void __init mm_init(void)
538{
539 /*
540 * page_cgroup requires countinous pages as memmap
541 * and it's bigger than MAX_ORDER unless SPARSEMEM.
542 */
543 page_cgroup_init_flatmem();
544 mem_init();
545 kmem_cache_init();
546 pgtable_cache_init();
547 vmalloc_init();
548}
549
536asmlinkage void __init start_kernel(void) 550asmlinkage void __init start_kernel(void)
537{ 551{
538 char * command_line; 552 char * command_line;
@@ -574,6 +588,23 @@ asmlinkage void __init start_kernel(void)
574 setup_nr_cpu_ids(); 588 setup_nr_cpu_ids();
575 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ 589 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
576 590
591 build_all_zonelists();
592 page_alloc_init();
593
594 printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
595 parse_early_param();
596 parse_args("Booting kernel", static_command_line, __start___param,
597 __stop___param - __start___param,
598 &unknown_bootoption);
599 /*
600 * These use large bootmem allocations and must precede
601 * kmem_cache_init()
602 */
603 pidhash_init();
604 vfs_caches_init_early();
605 sort_main_extable();
606 trap_init();
607 mm_init();
577 /* 608 /*
578 * Set up the scheduler prior starting any interrupts (such as the 609 * Set up the scheduler prior starting any interrupts (such as the
579 * timer interrupt). Full topology setup happens at smp_init() 610 * timer interrupt). Full topology setup happens at smp_init()
@@ -585,25 +616,16 @@ asmlinkage void __init start_kernel(void)
585 * fragile until we cpu_idle() for the first time. 616 * fragile until we cpu_idle() for the first time.
586 */ 617 */
587 preempt_disable(); 618 preempt_disable();
588 build_all_zonelists();
589 page_alloc_init();
590 printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
591 parse_early_param();
592 parse_args("Booting kernel", static_command_line, __start___param,
593 __stop___param - __start___param,
594 &unknown_bootoption);
595 if (!irqs_disabled()) { 619 if (!irqs_disabled()) {
596 printk(KERN_WARNING "start_kernel(): bug: interrupts were " 620 printk(KERN_WARNING "start_kernel(): bug: interrupts were "
597 "enabled *very* early, fixing it\n"); 621 "enabled *very* early, fixing it\n");
598 local_irq_disable(); 622 local_irq_disable();
599 } 623 }
600 sort_main_extable();
601 trap_init();
602 rcu_init(); 624 rcu_init();
603 /* init some links before init_ISA_irqs() */ 625 /* init some links before init_ISA_irqs() */
604 early_irq_init(); 626 early_irq_init();
605 init_IRQ(); 627 init_IRQ();
606 pidhash_init(); 628 prio_tree_init();
607 init_timers(); 629 init_timers();
608 hrtimers_init(); 630 hrtimers_init();
609 softirq_init(); 631 softirq_init();
@@ -617,6 +639,11 @@ asmlinkage void __init start_kernel(void)
617 early_boot_irqs_on(); 639 early_boot_irqs_on();
618 local_irq_enable(); 640 local_irq_enable();
619 641
642 /* Interrupts are enabled now so all GFP allocations are safe. */
643 set_gfp_allowed_mask(__GFP_BITS_MASK);
644
645 kmem_cache_init_late();
646
620 /* 647 /*
621 * HACK ALERT! This is early. We're enabling the console before 648 * HACK ALERT! This is early. We're enabling the console before
622 * we've done PCI setups etc, and console_init() must be aware of 649 * we've done PCI setups etc, and console_init() must be aware of
@@ -645,15 +672,10 @@ asmlinkage void __init start_kernel(void)
645 initrd_start = 0; 672 initrd_start = 0;
646 } 673 }
647#endif 674#endif
648 vmalloc_init();
649 vfs_caches_init_early();
650 cpuset_init_early();
651 page_cgroup_init(); 675 page_cgroup_init();
652 mem_init();
653 enable_debug_pagealloc(); 676 enable_debug_pagealloc();
654 cpu_hotplug_init();
655 kmem_cache_init();
656 kmemtrace_init(); 677 kmemtrace_init();
678 kmemleak_init();
657 debug_objects_mem_init(); 679 debug_objects_mem_init();
658 idr_init_cache(); 680 idr_init_cache();
659 setup_per_cpu_pageset(); 681 setup_per_cpu_pageset();
@@ -662,8 +684,6 @@ asmlinkage void __init start_kernel(void)
662 late_time_init(); 684 late_time_init();
663 calibrate_delay(); 685 calibrate_delay();
664 pidmap_init(); 686 pidmap_init();
665 pgtable_cache_init();
666 prio_tree_init();
667 anon_vma_init(); 687 anon_vma_init();
668#ifdef CONFIG_X86 688#ifdef CONFIG_X86
669 if (efi_enabled) 689 if (efi_enabled)
@@ -699,6 +719,17 @@ asmlinkage void __init start_kernel(void)
699 rest_init(); 719 rest_init();
700} 720}
701 721
722/* Call all constructor functions linked into the kernel. */
723static void __init do_ctors(void)
724{
725#ifdef CONFIG_CONSTRUCTORS
726 ctor_fn_t *call = (ctor_fn_t *) __ctors_start;
727
728 for (; call < (ctor_fn_t *) __ctors_end; call++)
729 (*call)();
730#endif
731}
732
702int initcall_debug; 733int initcall_debug;
703core_param(initcall_debug, initcall_debug, bool, 0644); 734core_param(initcall_debug, initcall_debug, bool, 0644);
704 735
@@ -779,6 +810,7 @@ static void __init do_basic_setup(void)
779 usermodehelper_init(); 810 usermodehelper_init();
780 driver_init(); 811 driver_init();
781 init_irq_proc(); 812 init_irq_proc();
813 do_ctors();
782 do_initcalls(); 814 do_initcalls();
783} 815}
784 816
@@ -846,6 +878,11 @@ static noinline int init_post(void)
846static int __init kernel_init(void * unused) 878static int __init kernel_init(void * unused)
847{ 879{
848 lock_kernel(); 880 lock_kernel();
881
882 /*
883 * init can allocate pages on any node
884 */
885 set_mems_allowed(node_possible_map);
849 /* 886 /*
850 * init can run on any cpu. 887 * init can run on any cpu.
851 */ 888 */