diff options
Diffstat (limited to 'init/main.c')
-rw-r--r-- | init/main.c | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/init/main.c b/init/main.c index 4051d75dd2d6..5c8540271529 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> |
@@ -69,6 +68,7 @@ | |||
69 | #include <linux/kmemtrace.h> | 68 | #include <linux/kmemtrace.h> |
70 | #include <linux/sfi.h> | 69 | #include <linux/sfi.h> |
71 | #include <linux/shmem_fs.h> | 70 | #include <linux/shmem_fs.h> |
71 | #include <linux/slab.h> | ||
72 | #include <trace/boot.h> | 72 | #include <trace/boot.h> |
73 | 73 | ||
74 | #include <asm/io.h> | 74 | #include <asm/io.h> |
@@ -149,6 +149,20 @@ static int __init nosmp(char *str) | |||
149 | 149 | ||
150 | early_param("nosmp", nosmp); | 150 | early_param("nosmp", nosmp); |
151 | 151 | ||
152 | /* this is hard limit */ | ||
153 | static int __init nrcpus(char *str) | ||
154 | { | ||
155 | int nr_cpus; | ||
156 | |||
157 | get_option(&str, &nr_cpus); | ||
158 | if (nr_cpus > 0 && nr_cpus < nr_cpu_ids) | ||
159 | nr_cpu_ids = nr_cpus; | ||
160 | |||
161 | return 0; | ||
162 | } | ||
163 | |||
164 | early_param("nr_cpus", nrcpus); | ||
165 | |||
152 | static int __init maxcpus(char *str) | 166 | static int __init maxcpus(char *str) |
153 | { | 167 | { |
154 | get_option(&str, &setup_max_cpus); | 168 | get_option(&str, &setup_max_cpus); |
@@ -160,7 +174,7 @@ static int __init maxcpus(char *str) | |||
160 | 174 | ||
161 | early_param("maxcpus", maxcpus); | 175 | early_param("maxcpus", maxcpus); |
162 | #else | 176 | #else |
163 | const unsigned int setup_max_cpus = NR_CPUS; | 177 | static const unsigned int setup_max_cpus = NR_CPUS; |
164 | #endif | 178 | #endif |
165 | 179 | ||
166 | /* | 180 | /* |
@@ -369,12 +383,6 @@ static void __init smp_init(void) | |||
369 | { | 383 | { |
370 | unsigned int cpu; | 384 | unsigned int cpu; |
371 | 385 | ||
372 | /* | ||
373 | * Set up the current CPU as possible to migrate to. | ||
374 | * The other ones will be done by cpu_up/cpu_down() | ||
375 | */ | ||
376 | set_cpu_active(smp_processor_id(), true); | ||
377 | |||
378 | /* FIXME: This should be done in userspace --RR */ | 386 | /* FIXME: This should be done in userspace --RR */ |
379 | for_each_present_cpu(cpu) { | 387 | for_each_present_cpu(cpu) { |
380 | if (num_online_cpus() >= setup_max_cpus) | 388 | if (num_online_cpus() >= setup_max_cpus) |
@@ -422,7 +430,9 @@ static noinline void __init_refok rest_init(void) | |||
422 | kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); | 430 | kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); |
423 | numa_default_policy(); | 431 | numa_default_policy(); |
424 | pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); | 432 | pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); |
433 | rcu_read_lock(); | ||
425 | kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); | 434 | kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); |
435 | rcu_read_unlock(); | ||
426 | unlock_kernel(); | 436 | unlock_kernel(); |
427 | 437 | ||
428 | /* | 438 | /* |
@@ -486,6 +496,7 @@ static void __init boot_cpu_init(void) | |||
486 | int cpu = smp_processor_id(); | 496 | int cpu = smp_processor_id(); |
487 | /* Mark the boot cpu "present", "online" etc for SMP and UP case */ | 497 | /* Mark the boot cpu "present", "online" etc for SMP and UP case */ |
488 | set_cpu_online(cpu, true); | 498 | set_cpu_online(cpu, true); |
499 | set_cpu_active(cpu, true); | ||
489 | set_cpu_present(cpu, true); | 500 | set_cpu_present(cpu, true); |
490 | set_cpu_possible(cpu, true); | 501 | set_cpu_possible(cpu, true); |
491 | } | 502 | } |
@@ -589,6 +600,7 @@ asmlinkage void __init start_kernel(void) | |||
589 | local_irq_disable(); | 600 | local_irq_disable(); |
590 | } | 601 | } |
591 | rcu_init(); | 602 | rcu_init(); |
603 | radix_tree_init(); | ||
592 | /* init some links before init_ISA_irqs() */ | 604 | /* init some links before init_ISA_irqs() */ |
593 | early_irq_init(); | 605 | early_irq_init(); |
594 | init_IRQ(); | 606 | init_IRQ(); |
@@ -606,7 +618,7 @@ asmlinkage void __init start_kernel(void) | |||
606 | local_irq_enable(); | 618 | local_irq_enable(); |
607 | 619 | ||
608 | /* Interrupts are enabled now so all GFP allocations are safe. */ | 620 | /* Interrupts are enabled now so all GFP allocations are safe. */ |
609 | set_gfp_allowed_mask(__GFP_BITS_MASK); | 621 | gfp_allowed_mask = __GFP_BITS_MASK; |
610 | 622 | ||
611 | kmem_cache_init_late(); | 623 | kmem_cache_init_late(); |
612 | 624 | ||
@@ -664,7 +676,6 @@ asmlinkage void __init start_kernel(void) | |||
664 | key_init(); | 676 | key_init(); |
665 | security_init(); | 677 | security_init(); |
666 | vfs_caches_init(totalram_pages); | 678 | vfs_caches_init(totalram_pages); |
667 | radix_tree_init(); | ||
668 | signals_init(); | 679 | signals_init(); |
669 | /* rootfs populating might need page-writeback */ | 680 | /* rootfs populating might need page-writeback */ |
670 | page_writeback_init(); | 681 | page_writeback_init(); |
@@ -691,10 +702,10 @@ asmlinkage void __init start_kernel(void) | |||
691 | static void __init do_ctors(void) | 702 | static void __init do_ctors(void) |
692 | { | 703 | { |
693 | #ifdef CONFIG_CONSTRUCTORS | 704 | #ifdef CONFIG_CONSTRUCTORS |
694 | ctor_fn_t *call = (ctor_fn_t *) __ctors_start; | 705 | ctor_fn_t *fn = (ctor_fn_t *) __ctors_start; |
695 | 706 | ||
696 | for (; call < (ctor_fn_t *) __ctors_end; call++) | 707 | for (; fn < (ctor_fn_t *) __ctors_end; fn++) |
697 | (*call)(); | 708 | (*fn)(); |
698 | #endif | 709 | #endif |
699 | } | 710 | } |
700 | 711 | ||
@@ -755,10 +766,10 @@ extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[]; | |||
755 | 766 | ||
756 | static void __init do_initcalls(void) | 767 | static void __init do_initcalls(void) |
757 | { | 768 | { |
758 | initcall_t *call; | 769 | initcall_t *fn; |
759 | 770 | ||
760 | for (call = __early_initcall_end; call < __initcall_end; call++) | 771 | for (fn = __early_initcall_end; fn < __initcall_end; fn++) |
761 | do_one_initcall(*call); | 772 | do_one_initcall(*fn); |
762 | 773 | ||
763 | /* Make sure there is no pending stuff from the initcall sequence */ | 774 | /* Make sure there is no pending stuff from the initcall sequence */ |
764 | flush_scheduled_work(); | 775 | flush_scheduled_work(); |
@@ -785,10 +796,10 @@ static void __init do_basic_setup(void) | |||
785 | 796 | ||
786 | static void __init do_pre_smp_initcalls(void) | 797 | static void __init do_pre_smp_initcalls(void) |
787 | { | 798 | { |
788 | initcall_t *call; | 799 | initcall_t *fn; |
789 | 800 | ||
790 | for (call = __initcall_start; call < __early_initcall_end; call++) | 801 | for (fn = __initcall_start; fn < __early_initcall_end; fn++) |
791 | do_one_initcall(*call); | 802 | do_one_initcall(*fn); |
792 | } | 803 | } |
793 | 804 | ||
794 | static void run_init_process(char *init_filename) | 805 | static void run_init_process(char *init_filename) |
@@ -811,11 +822,6 @@ static noinline int init_post(void) | |||
811 | system_state = SYSTEM_RUNNING; | 822 | system_state = SYSTEM_RUNNING; |
812 | numa_default_policy(); | 823 | numa_default_policy(); |
813 | 824 | ||
814 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
815 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
816 | |||
817 | (void) sys_dup(0); | ||
818 | (void) sys_dup(0); | ||
819 | 825 | ||
820 | current->signal->flags |= SIGNAL_UNKILLABLE; | 826 | current->signal->flags |= SIGNAL_UNKILLABLE; |
821 | 827 | ||
@@ -841,7 +847,8 @@ static noinline int init_post(void) | |||
841 | run_init_process("/bin/init"); | 847 | run_init_process("/bin/init"); |
842 | run_init_process("/bin/sh"); | 848 | run_init_process("/bin/sh"); |
843 | 849 | ||
844 | panic("No init found. Try passing init= option to kernel."); | 850 | panic("No init found. Try passing init= option to kernel. " |
851 | "See Linux Documentation/init.txt for guidance."); | ||
845 | } | 852 | } |
846 | 853 | ||
847 | static int __init kernel_init(void * unused) | 854 | static int __init kernel_init(void * unused) |
@@ -851,7 +858,7 @@ static int __init kernel_init(void * unused) | |||
851 | /* | 858 | /* |
852 | * init can allocate pages on any node | 859 | * init can allocate pages on any node |
853 | */ | 860 | */ |
854 | set_mems_allowed(node_possible_map); | 861 | set_mems_allowed(node_states[N_HIGH_MEMORY]); |
855 | /* | 862 | /* |
856 | * init can run on any cpu. | 863 | * init can run on any cpu. |
857 | */ | 864 | */ |
@@ -878,6 +885,12 @@ static int __init kernel_init(void * unused) | |||
878 | 885 | ||
879 | do_basic_setup(); | 886 | do_basic_setup(); |
880 | 887 | ||
888 | /* Open the /dev/console on the rootfs, this should never fail */ | ||
889 | if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0) | ||
890 | printk(KERN_WARNING "Warning: unable to open an initial console.\n"); | ||
891 | |||
892 | (void) sys_dup(0); | ||
893 | (void) sys_dup(0); | ||
881 | /* | 894 | /* |
882 | * check if there is an early userspace init. If yes, let it do all | 895 | * check if there is an early userspace init. If yes, let it do all |
883 | * the work | 896 | * the work |