diff options
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/init/main.c b/init/main.c index dac44a9356a5..3bdb152f412f 100644 --- a/init/main.c +++ b/init/main.c | |||
@@ -25,7 +25,6 @@ | |||
25 | #include <linux/bootmem.h> | 25 | #include <linux/bootmem.h> |
26 | #include <linux/acpi.h> | 26 | #include <linux/acpi.h> |
27 | #include <linux/tty.h> | 27 | #include <linux/tty.h> |
28 | #include <linux/gfp.h> | ||
29 | #include <linux/percpu.h> | 28 | #include <linux/percpu.h> |
30 | #include <linux/kmod.h> | 29 | #include <linux/kmod.h> |
31 | #include <linux/vmalloc.h> | 30 | #include <linux/vmalloc.h> |
@@ -63,12 +62,14 @@ | |||
63 | #include <linux/sched.h> | 62 | #include <linux/sched.h> |
64 | #include <linux/signal.h> | 63 | #include <linux/signal.h> |
65 | #include <linux/idr.h> | 64 | #include <linux/idr.h> |
65 | #include <linux/kgdb.h> | ||
66 | #include <linux/ftrace.h> | 66 | #include <linux/ftrace.h> |
67 | #include <linux/async.h> | 67 | #include <linux/async.h> |
68 | #include <linux/kmemcheck.h> | 68 | #include <linux/kmemcheck.h> |
69 | #include <linux/kmemtrace.h> | 69 | #include <linux/kmemtrace.h> |
70 | #include <linux/sfi.h> | 70 | #include <linux/sfi.h> |
71 | #include <linux/shmem_fs.h> | 71 | #include <linux/shmem_fs.h> |
72 | #include <linux/slab.h> | ||
72 | #include <trace/boot.h> | 73 | #include <trace/boot.h> |
73 | 74 | ||
74 | #include <asm/io.h> | 75 | #include <asm/io.h> |
@@ -149,6 +150,20 @@ static int __init nosmp(char *str) | |||
149 | 150 | ||
150 | early_param("nosmp", nosmp); | 151 | early_param("nosmp", nosmp); |
151 | 152 | ||
153 | /* this is hard limit */ | ||
154 | static int __init nrcpus(char *str) | ||
155 | { | ||
156 | int nr_cpus; | ||
157 | |||
158 | get_option(&str, &nr_cpus); | ||
159 | if (nr_cpus > 0 && nr_cpus < nr_cpu_ids) | ||
160 | nr_cpu_ids = nr_cpus; | ||
161 | |||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | early_param("nr_cpus", nrcpus); | ||
166 | |||
152 | static int __init maxcpus(char *str) | 167 | static int __init maxcpus(char *str) |
153 | { | 168 | { |
154 | get_option(&str, &setup_max_cpus); | 169 | get_option(&str, &setup_max_cpus); |
@@ -160,7 +175,7 @@ static int __init maxcpus(char *str) | |||
160 | 175 | ||
161 | early_param("maxcpus", maxcpus); | 176 | early_param("maxcpus", maxcpus); |
162 | #else | 177 | #else |
163 | const unsigned int setup_max_cpus = NR_CPUS; | 178 | static const unsigned int setup_max_cpus = NR_CPUS; |
164 | #endif | 179 | #endif |
165 | 180 | ||
166 | /* | 181 | /* |
@@ -416,7 +431,9 @@ static noinline void __init_refok rest_init(void) | |||
416 | kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); | 431 | kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); |
417 | numa_default_policy(); | 432 | numa_default_policy(); |
418 | pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); | 433 | pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); |
434 | rcu_read_lock(); | ||
419 | kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); | 435 | kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); |
436 | rcu_read_unlock(); | ||
420 | unlock_kernel(); | 437 | unlock_kernel(); |
421 | 438 | ||
422 | /* | 439 | /* |
@@ -550,7 +567,7 @@ asmlinkage void __init start_kernel(void) | |||
550 | setup_per_cpu_areas(); | 567 | setup_per_cpu_areas(); |
551 | smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ | 568 | smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ |
552 | 569 | ||
553 | build_all_zonelists(); | 570 | build_all_zonelists(NULL); |
554 | page_alloc_init(); | 571 | page_alloc_init(); |
555 | 572 | ||
556 | printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line); | 573 | printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line); |
@@ -584,6 +601,7 @@ asmlinkage void __init start_kernel(void) | |||
584 | local_irq_disable(); | 601 | local_irq_disable(); |
585 | } | 602 | } |
586 | rcu_init(); | 603 | rcu_init(); |
604 | radix_tree_init(); | ||
587 | /* init some links before init_ISA_irqs() */ | 605 | /* init some links before init_ISA_irqs() */ |
588 | early_irq_init(); | 606 | early_irq_init(); |
589 | init_IRQ(); | 607 | init_IRQ(); |
@@ -601,7 +619,7 @@ asmlinkage void __init start_kernel(void) | |||
601 | local_irq_enable(); | 619 | local_irq_enable(); |
602 | 620 | ||
603 | /* Interrupts are enabled now so all GFP allocations are safe. */ | 621 | /* Interrupts are enabled now so all GFP allocations are safe. */ |
604 | set_gfp_allowed_mask(__GFP_BITS_MASK); | 622 | gfp_allowed_mask = __GFP_BITS_MASK; |
605 | 623 | ||
606 | kmem_cache_init_late(); | 624 | kmem_cache_init_late(); |
607 | 625 | ||
@@ -658,8 +676,8 @@ asmlinkage void __init start_kernel(void) | |||
658 | buffer_init(); | 676 | buffer_init(); |
659 | key_init(); | 677 | key_init(); |
660 | security_init(); | 678 | security_init(); |
679 | dbg_late_init(); | ||
661 | vfs_caches_init(totalram_pages); | 680 | vfs_caches_init(totalram_pages); |
662 | radix_tree_init(); | ||
663 | signals_init(); | 681 | signals_init(); |
664 | /* rootfs populating might need page-writeback */ | 682 | /* rootfs populating might need page-writeback */ |
665 | page_writeback_init(); | 683 | page_writeback_init(); |
@@ -806,11 +824,6 @@ static noinline int init_post(void) | |||
806 | system_state = SYSTEM_RUNNING; | 824 | system_state = SYSTEM_RUNNING; |
807 | numa_default_policy(); | 825 | numa_default_policy(); |
808 | 826 | ||
809 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
810 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
811 | |||
812 | (void) sys_dup(0); | ||
813 | (void) sys_dup(0); | ||
814 | 827 | ||
815 | current->signal->flags |= SIGNAL_UNKILLABLE; | 828 | current->signal->flags |= SIGNAL_UNKILLABLE; |
816 | 829 | ||
@@ -836,7 +849,8 @@ static noinline int init_post(void) | |||
836 | run_init_process("/bin/init"); | 849 | run_init_process("/bin/init"); |
837 | run_init_process("/bin/sh"); | 850 | run_init_process("/bin/sh"); |
838 | 851 | ||
839 | panic("No init found. Try passing init= option to kernel."); | 852 | panic("No init found. Try passing init= option to kernel. " |
853 | "See Linux Documentation/init.txt for guidance."); | ||
840 | } | 854 | } |
841 | 855 | ||
842 | static int __init kernel_init(void * unused) | 856 | static int __init kernel_init(void * unused) |
@@ -846,7 +860,7 @@ static int __init kernel_init(void * unused) | |||
846 | /* | 860 | /* |
847 | * init can allocate pages on any node | 861 | * init can allocate pages on any node |
848 | */ | 862 | */ |
849 | set_mems_allowed(node_possible_map); | 863 | set_mems_allowed(node_states[N_HIGH_MEMORY]); |
850 | /* | 864 | /* |
851 | * init can run on any cpu. | 865 | * init can run on any cpu. |
852 | */ | 866 | */ |
@@ -873,6 +887,12 @@ static int __init kernel_init(void * unused) | |||
873 | 887 | ||
874 | do_basic_setup(); | 888 | do_basic_setup(); |
875 | 889 | ||
890 | /* Open the /dev/console on the rootfs, this should never fail */ | ||
891 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
892 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
893 | |||
894 | (void) sys_dup(0); | ||
895 | (void) sys_dup(0); | ||
876 | /* | 896 | /* |
877 | * check if there is an early userspace init. If yes, let it do all | 897 | * check if there is an early userspace init. If yes, let it do all |
878 | * the work | 898 | * the work |