aboutsummaryrefslogtreecommitdiffstats
path: root/init/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'init/main.c')
-rw-r--r--init/main.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/init/main.c b/init/main.c
index 5f2ec2cdd900..e97fadeec856 100644
--- a/init/main.c
+++ b/init/main.c
@@ -65,11 +65,9 @@
65#include <linux/ftrace.h> 65#include <linux/ftrace.h>
66#include <linux/async.h> 66#include <linux/async.h>
67#include <linux/kmemcheck.h> 67#include <linux/kmemcheck.h>
68#include <linux/kmemtrace.h>
69#include <linux/sfi.h> 68#include <linux/sfi.h>
70#include <linux/shmem_fs.h> 69#include <linux/shmem_fs.h>
71#include <linux/slab.h> 70#include <linux/slab.h>
72#include <trace/boot.h>
73 71
74#include <asm/io.h> 72#include <asm/io.h>
75#include <asm/bugs.h> 73#include <asm/bugs.h>
@@ -124,7 +122,9 @@ static char *ramdisk_execute_command;
124 122
125#ifdef CONFIG_SMP 123#ifdef CONFIG_SMP
126/* Setup configured maximum number of CPUs to activate */ 124/* Setup configured maximum number of CPUs to activate */
127unsigned int __initdata setup_max_cpus = NR_CPUS; 125unsigned int setup_max_cpus = NR_CPUS;
126EXPORT_SYMBOL(setup_max_cpus);
127
128 128
129/* 129/*
130 * Setup routine for controlling SMP activation 130 * Setup routine for controlling SMP activation
@@ -421,18 +421,26 @@ static void __init setup_command_line(char *command_line)
421 * gcc-3.4 accidentally inlines this function, so use noinline. 421 * gcc-3.4 accidentally inlines this function, so use noinline.
422 */ 422 */
423 423
424static __initdata DECLARE_COMPLETION(kthreadd_done);
425
424static noinline void __init_refok rest_init(void) 426static noinline void __init_refok rest_init(void)
425 __releases(kernel_lock) 427 __releases(kernel_lock)
426{ 428{
427 int pid; 429 int pid;
428 430
429 rcu_scheduler_starting(); 431 rcu_scheduler_starting();
432 /*
433 * We need to spawn init first so that it obtains pid 1, however
434 * the init task will end up wanting to create kthreads, which, if
435 * we schedule it before we create kthreadd, will OOPS.
436 */
430 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); 437 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
431 numa_default_policy(); 438 numa_default_policy();
432 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES); 439 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
433 rcu_read_lock(); 440 rcu_read_lock();
434 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns); 441 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
435 rcu_read_unlock(); 442 rcu_read_unlock();
443 complete(&kthreadd_done);
436 unlock_kernel(); 444 unlock_kernel();
437 445
438 /* 446 /*
@@ -521,6 +529,7 @@ static void __init mm_init(void)
521 page_cgroup_init_flatmem(); 529 page_cgroup_init_flatmem();
522 mem_init(); 530 mem_init();
523 kmem_cache_init(); 531 kmem_cache_init();
532 percpu_init_late();
524 pgtable_cache_init(); 533 pgtable_cache_init();
525 vmalloc_init(); 534 vmalloc_init();
526} 535}
@@ -652,7 +661,6 @@ asmlinkage void __init start_kernel(void)
652#endif 661#endif
653 page_cgroup_init(); 662 page_cgroup_init();
654 enable_debug_pagealloc(); 663 enable_debug_pagealloc();
655 kmemtrace_init();
656 kmemleak_init(); 664 kmemleak_init();
657 debug_objects_mem_init(); 665 debug_objects_mem_init();
658 idr_init_cache(); 666 idr_init_cache();
@@ -714,38 +722,33 @@ int initcall_debug;
714core_param(initcall_debug, initcall_debug, bool, 0644); 722core_param(initcall_debug, initcall_debug, bool, 0644);
715 723
716static char msgbuf[64]; 724static char msgbuf[64];
717static struct boot_trace_call call;
718static struct boot_trace_ret ret;
719 725
720int do_one_initcall(initcall_t fn) 726int do_one_initcall(initcall_t fn)
721{ 727{
722 int count = preempt_count(); 728 int count = preempt_count();
723 ktime_t calltime, delta, rettime; 729 ktime_t calltime, delta, rettime;
730 unsigned long long duration;
731 int ret;
724 732
725 if (initcall_debug) { 733 if (initcall_debug) {
726 call.caller = task_pid_nr(current); 734 printk("calling %pF @ %i\n", fn, task_pid_nr(current));
727 printk("calling %pF @ %i\n", fn, call.caller);
728 calltime = ktime_get(); 735 calltime = ktime_get();
729 trace_boot_call(&call, fn);
730 enable_boot_trace();
731 } 736 }
732 737
733 ret.result = fn(); 738 ret = fn();
734 739
735 if (initcall_debug) { 740 if (initcall_debug) {
736 disable_boot_trace();
737 rettime = ktime_get(); 741 rettime = ktime_get();
738 delta = ktime_sub(rettime, calltime); 742 delta = ktime_sub(rettime, calltime);
739 ret.duration = (unsigned long long) ktime_to_ns(delta) >> 10; 743 duration = (unsigned long long) ktime_to_ns(delta) >> 10;
740 trace_boot_ret(&ret, fn); 744 printk("initcall %pF returned %d after %lld usecs\n", fn,
741 printk("initcall %pF returned %d after %Ld usecs\n", fn, 745 ret, duration);
742 ret.result, ret.duration);
743 } 746 }
744 747
745 msgbuf[0] = 0; 748 msgbuf[0] = 0;
746 749
747 if (ret.result && ret.result != -ENODEV && initcall_debug) 750 if (ret && ret != -ENODEV && initcall_debug)
748 sprintf(msgbuf, "error code %d ", ret.result); 751 sprintf(msgbuf, "error code %d ", ret);
749 752
750 if (preempt_count() != count) { 753 if (preempt_count() != count) {
751 strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf)); 754 strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
@@ -759,7 +762,7 @@ int do_one_initcall(initcall_t fn)
759 printk("initcall %pF returned with %s\n", fn, msgbuf); 762 printk("initcall %pF returned with %s\n", fn, msgbuf);
760 } 763 }
761 764
762 return ret.result; 765 return ret;
763} 766}
764 767
765 768
@@ -853,6 +856,10 @@ static noinline int init_post(void)
853 856
854static int __init kernel_init(void * unused) 857static int __init kernel_init(void * unused)
855{ 858{
859 /*
860 * Wait until kthreadd is all set-up.
861 */
862 wait_for_completion(&kthreadd_done);
856 lock_kernel(); 863 lock_kernel();
857 864
858 /* 865 /*
@@ -878,7 +885,6 @@ static int __init kernel_init(void * unused)
878 smp_prepare_cpus(setup_max_cpus); 885 smp_prepare_cpus(setup_max_cpus);
879 886
880 do_pre_smp_initcalls(); 887 do_pre_smp_initcalls();
881 start_boot_trace();
882 888
883 smp_init(); 889 smp_init();
884 sched_init_smp(); 890 sched_init_smp();