aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c78
1 files changed, 60 insertions, 18 deletions
diff --git a/init/main.c b/init/main.c
index d721dad05dd7..09131ec090c1 100644
--- a/init/main.c
+++ b/init/main.c
@@ -56,6 +56,7 @@
56#include <linux/debug_locks.h> 56#include <linux/debug_locks.h>
57#include <linux/debugobjects.h> 57#include <linux/debugobjects.h>
58#include <linux/lockdep.h> 58#include <linux/lockdep.h>
59#include <linux/kmemleak.h>
59#include <linux/pid_namespace.h> 60#include <linux/pid_namespace.h>
60#include <linux/device.h> 61#include <linux/device.h>
61#include <linux/kthread.h> 62#include <linux/kthread.h>
@@ -64,6 +65,8 @@
64#include <linux/idr.h> 65#include <linux/idr.h>
65#include <linux/ftrace.h> 66#include <linux/ftrace.h>
66#include <linux/async.h> 67#include <linux/async.h>
68#include <linux/kmemcheck.h>
69#include <linux/kmemtrace.h>
67#include <trace/boot.h> 70#include <trace/boot.h>
68 71
69#include <asm/io.h> 72#include <asm/io.h>
@@ -71,7 +74,6 @@
71#include <asm/setup.h> 74#include <asm/setup.h>
72#include <asm/sections.h> 75#include <asm/sections.h>
73#include <asm/cacheflush.h> 76#include <asm/cacheflush.h>
74#include <trace/kmemtrace.h>
75 77
76#ifdef CONFIG_X86_LOCAL_APIC 78#ifdef CONFIG_X86_LOCAL_APIC
77#include <asm/smp.h> 79#include <asm/smp.h>
@@ -533,6 +535,22 @@ void __init __weak thread_info_cache_init(void)
533{ 535{
534} 536}
535 537
538/*
539 * Set up kernel memory allocators
540 */
541static void __init mm_init(void)
542{
543 /*
544 * page_cgroup requires countinous pages as memmap
545 * and it's bigger than MAX_ORDER unless SPARSEMEM.
546 */
547 page_cgroup_init_flatmem();
548 mem_init();
549 kmem_cache_init();
550 pgtable_cache_init();
551 vmalloc_init();
552}
553
536asmlinkage void __init start_kernel(void) 554asmlinkage void __init start_kernel(void)
537{ 555{
538 char * command_line; 556 char * command_line;
@@ -574,6 +592,23 @@ asmlinkage void __init start_kernel(void)
574 setup_nr_cpu_ids(); 592 setup_nr_cpu_ids();
575 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ 593 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
576 594
595 build_all_zonelists();
596 page_alloc_init();
597
598 printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
599 parse_early_param();
600 parse_args("Booting kernel", static_command_line, __start___param,
601 __stop___param - __start___param,
602 &unknown_bootoption);
603 /*
604 * These use large bootmem allocations and must precede
605 * kmem_cache_init()
606 */
607 pidhash_init();
608 vfs_caches_init_early();
609 sort_main_extable();
610 trap_init();
611 mm_init();
577 /* 612 /*
578 * Set up the scheduler prior starting any interrupts (such as the 613 * Set up the scheduler prior starting any interrupts (such as the
579 * timer interrupt). Full topology setup happens at smp_init() 614 * timer interrupt). Full topology setup happens at smp_init()
@@ -585,25 +620,16 @@ asmlinkage void __init start_kernel(void)
585 * fragile until we cpu_idle() for the first time. 620 * fragile until we cpu_idle() for the first time.
586 */ 621 */
587 preempt_disable(); 622 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()) { 623 if (!irqs_disabled()) {
596 printk(KERN_WARNING "start_kernel(): bug: interrupts were " 624 printk(KERN_WARNING "start_kernel(): bug: interrupts were "
597 "enabled *very* early, fixing it\n"); 625 "enabled *very* early, fixing it\n");
598 local_irq_disable(); 626 local_irq_disable();
599 } 627 }
600 sort_main_extable();
601 trap_init();
602 rcu_init(); 628 rcu_init();
603 /* init some links before init_ISA_irqs() */ 629 /* init some links before init_ISA_irqs() */
604 early_irq_init(); 630 early_irq_init();
605 init_IRQ(); 631 init_IRQ();
606 pidhash_init(); 632 prio_tree_init();
607 init_timers(); 633 init_timers();
608 hrtimers_init(); 634 hrtimers_init();
609 softirq_init(); 635 softirq_init();
@@ -617,6 +643,11 @@ asmlinkage void __init start_kernel(void)
617 early_boot_irqs_on(); 643 early_boot_irqs_on();
618 local_irq_enable(); 644 local_irq_enable();
619 645
646 /* Interrupts are enabled now so all GFP allocations are safe. */
647 set_gfp_allowed_mask(__GFP_BITS_MASK);
648
649 kmem_cache_init_late();
650
620 /* 651 /*
621 * HACK ALERT! This is early. We're enabling the console before 652 * 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 653 * we've done PCI setups etc, and console_init() must be aware of
@@ -645,15 +676,11 @@ asmlinkage void __init start_kernel(void)
645 initrd_start = 0; 676 initrd_start = 0;
646 } 677 }
647#endif 678#endif
648 vmalloc_init();
649 vfs_caches_init_early();
650 cpuset_init_early();
651 page_cgroup_init(); 679 page_cgroup_init();
652 mem_init();
653 enable_debug_pagealloc(); 680 enable_debug_pagealloc();
654 cpu_hotplug_init(); 681 cpu_hotplug_init();
655 kmem_cache_init();
656 kmemtrace_init(); 682 kmemtrace_init();
683 kmemleak_init();
657 debug_objects_mem_init(); 684 debug_objects_mem_init();
658 idr_init_cache(); 685 idr_init_cache();
659 setup_per_cpu_pageset(); 686 setup_per_cpu_pageset();
@@ -662,8 +689,6 @@ asmlinkage void __init start_kernel(void)
662 late_time_init(); 689 late_time_init();
663 calibrate_delay(); 690 calibrate_delay();
664 pidmap_init(); 691 pidmap_init();
665 pgtable_cache_init();
666 prio_tree_init();
667 anon_vma_init(); 692 anon_vma_init();
668#ifdef CONFIG_X86 693#ifdef CONFIG_X86
669 if (efi_enabled) 694 if (efi_enabled)
@@ -699,6 +724,17 @@ asmlinkage void __init start_kernel(void)
699 rest_init(); 724 rest_init();
700} 725}
701 726
727/* Call all constructor functions linked into the kernel. */
728static void __init do_ctors(void)
729{
730#ifdef CONFIG_CONSTRUCTORS
731 ctor_fn_t *call = (ctor_fn_t *) __ctors_start;
732
733 for (; call < (ctor_fn_t *) __ctors_end; call++)
734 (*call)();
735#endif
736}
737
702int initcall_debug; 738int initcall_debug;
703core_param(initcall_debug, initcall_debug, bool, 0644); 739core_param(initcall_debug, initcall_debug, bool, 0644);
704 740
@@ -779,6 +815,7 @@ static void __init do_basic_setup(void)
779 usermodehelper_init(); 815 usermodehelper_init();
780 driver_init(); 816 driver_init();
781 init_irq_proc(); 817 init_irq_proc();
818 do_ctors();
782 do_initcalls(); 819 do_initcalls();
783} 820}
784 821
@@ -846,6 +883,11 @@ static noinline int init_post(void)
846static int __init kernel_init(void * unused) 883static int __init kernel_init(void * unused)
847{ 884{
848 lock_kernel(); 885 lock_kernel();
886
887 /*
888 * init can allocate pages on any node
889 */
890 set_mems_allowed(node_possible_map);
849 /* 891 /*
850 * init can run on any cpu. 892 * init can run on any cpu.
851 */ 893 */