aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c79
1 files changed, 60 insertions, 19 deletions
diff --git a/init/main.c b/init/main.c
index f1b9f0fdb1b4..2c5ade79eb81 100644
--- a/init/main.c
+++ b/init/main.c
@@ -57,6 +57,7 @@
57#include <linux/debug_locks.h> 57#include <linux/debug_locks.h>
58#include <linux/debugobjects.h> 58#include <linux/debugobjects.h>
59#include <linux/lockdep.h> 59#include <linux/lockdep.h>
60#include <linux/kmemleak.h>
60#include <linux/pid_namespace.h> 61#include <linux/pid_namespace.h>
61#include <linux/device.h> 62#include <linux/device.h>
62#include <linux/kthread.h> 63#include <linux/kthread.h>
@@ -65,6 +66,8 @@
65#include <linux/idr.h> 66#include <linux/idr.h>
66#include <linux/ftrace.h> 67#include <linux/ftrace.h>
67#include <linux/async.h> 68#include <linux/async.h>
69#include <linux/kmemcheck.h>
70#include <linux/kmemtrace.h>
68#include <trace/boot.h> 71#include <trace/boot.h>
69 72
70#include <asm/io.h> 73#include <asm/io.h>
@@ -72,7 +75,6 @@
72#include <asm/setup.h> 75#include <asm/setup.h>
73#include <asm/sections.h> 76#include <asm/sections.h>
74#include <asm/cacheflush.h> 77#include <asm/cacheflush.h>
75#include <trace/kmemtrace.h>
76 78
77#ifdef CONFIG_X86_LOCAL_APIC 79#ifdef CONFIG_X86_LOCAL_APIC
78#include <asm/smp.h> 80#include <asm/smp.h>
@@ -529,6 +531,22 @@ void __init __weak thread_info_cache_init(void)
529{ 531{
530} 532}
531 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
532asmlinkage void __init start_kernel(void) 550asmlinkage void __init start_kernel(void)
533{ 551{
534 char * command_line; 552 char * command_line;
@@ -570,6 +588,23 @@ asmlinkage void __init start_kernel(void)
570 setup_nr_cpu_ids(); 588 setup_nr_cpu_ids();
571 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ 589 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
572 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();
573 /* 608 /*
574 * Set up the scheduler prior starting any interrupts (such as the 609 * Set up the scheduler prior starting any interrupts (such as the
575 * timer interrupt). Full topology setup happens at smp_init() 610 * timer interrupt). Full topology setup happens at smp_init()
@@ -581,25 +616,16 @@ asmlinkage void __init start_kernel(void)
581 * fragile until we cpu_idle() for the first time. 616 * fragile until we cpu_idle() for the first time.
582 */ 617 */
583 preempt_disable(); 618 preempt_disable();
584 build_all_zonelists();
585 page_alloc_init();
586 printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
587 parse_early_param();
588 parse_args("Booting kernel", static_command_line, __start___param,
589 __stop___param - __start___param,
590 &unknown_bootoption);
591 if (!irqs_disabled()) { 619 if (!irqs_disabled()) {
592 printk(KERN_WARNING "start_kernel(): bug: interrupts were " 620 printk(KERN_WARNING "start_kernel(): bug: interrupts were "
593 "enabled *very* early, fixing it\n"); 621 "enabled *very* early, fixing it\n");
594 local_irq_disable(); 622 local_irq_disable();
595 } 623 }
596 sort_main_extable();
597 trap_init();
598 rcu_init(); 624 rcu_init();
599 /* init some links before init_ISA_irqs() */ 625 /* init some links before init_ISA_irqs() */
600 early_irq_init(); 626 early_irq_init();
601 init_IRQ(); 627 init_IRQ();
602 pidhash_init(); 628 prio_tree_init();
603 init_timers(); 629 init_timers();
604 hrtimers_init(); 630 hrtimers_init();
605 softirq_init(); 631 softirq_init();
@@ -613,6 +639,11 @@ asmlinkage void __init start_kernel(void)
613 early_boot_irqs_on(); 639 early_boot_irqs_on();
614 local_irq_enable(); 640 local_irq_enable();
615 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
616 /* 647 /*
617 * HACK ALERT! This is early. We're enabling the console before 648 * HACK ALERT! This is early. We're enabling the console before
618 * 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
@@ -641,15 +672,10 @@ asmlinkage void __init start_kernel(void)
641 initrd_start = 0; 672 initrd_start = 0;
642 } 673 }
643#endif 674#endif
644 vmalloc_init();
645 vfs_caches_init_early();
646 cpuset_init_early();
647 page_cgroup_init(); 675 page_cgroup_init();
648 mem_init();
649 enable_debug_pagealloc(); 676 enable_debug_pagealloc();
650 cpu_hotplug_init();
651 kmem_cache_init();
652 kmemtrace_init(); 677 kmemtrace_init();
678 kmemleak_init();
653 debug_objects_mem_init(); 679 debug_objects_mem_init();
654 idr_init_cache(); 680 idr_init_cache();
655 setup_per_cpu_pageset(); 681 setup_per_cpu_pageset();
@@ -658,8 +684,6 @@ asmlinkage void __init start_kernel(void)
658 late_time_init(); 684 late_time_init();
659 calibrate_delay(); 685 calibrate_delay();
660 pidmap_init(); 686 pidmap_init();
661 pgtable_cache_init();
662 prio_tree_init();
663 anon_vma_init(); 687 anon_vma_init();
664#ifdef CONFIG_X86 688#ifdef CONFIG_X86
665 if (efi_enabled) 689 if (efi_enabled)
@@ -695,6 +719,17 @@ asmlinkage void __init start_kernel(void)
695 rest_init(); 719 rest_init();
696} 720}
697 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
698int initcall_debug; 733int initcall_debug;
699core_param(initcall_debug, initcall_debug, bool, 0644); 734core_param(initcall_debug, initcall_debug, bool, 0644);
700 735
@@ -775,6 +810,7 @@ static void __init do_basic_setup(void)
775 usermodehelper_init(); 810 usermodehelper_init();
776 driver_init(); 811 driver_init();
777 init_irq_proc(); 812 init_irq_proc();
813 do_ctors();
778 do_initcalls(); 814 do_initcalls();
779} 815}
780 816
@@ -842,6 +878,11 @@ static noinline int init_post(void)
842static int __init kernel_init(void * unused) 878static int __init kernel_init(void * unused)
843{ 879{
844 lock_kernel(); 880 lock_kernel();
881
882 /*
883 * init can allocate pages on any node
884 */
885 set_mems_allowed(node_possible_map);
845 /* 886 /*
846 * init can run on any cpu. 887 * init can run on any cpu.
847 */ 888 */