main.c (96916090f488986a4ebb8e9ffa6a3b50881d5ccd) main.c (3e51f33fcc7f55e6df25d15b55ed10c8b4da84cd)
1/*
2 * linux/init/main.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * GK 2/5/95 - Changed to support mounting root fs via NFS
7 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
8 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96

--- 38 unchanged lines hidden (view full) ---

47#include <linux/delayacct.h>
48#include <linux/unistd.h>
49#include <linux/rmap.h>
50#include <linux/mempolicy.h>
51#include <linux/key.h>
52#include <linux/unwind.h>
53#include <linux/buffer_head.h>
54#include <linux/debug_locks.h>
1/*
2 * linux/init/main.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 *
6 * GK 2/5/95 - Changed to support mounting root fs via NFS
7 * Added initrd & change_root: Werner Almesberger & Hans Lermen, Feb '96
8 * Moan early if gcc is old, avoiding bogus kernels - Paul Gortmaker, May '96

--- 38 unchanged lines hidden (view full) ---

47#include <linux/delayacct.h>
48#include <linux/unistd.h>
49#include <linux/rmap.h>
50#include <linux/mempolicy.h>
51#include <linux/key.h>
52#include <linux/unwind.h>
53#include <linux/buffer_head.h>
54#include <linux/debug_locks.h>
55#include <linux/debugobjects.h>
55#include <linux/lockdep.h>
56#include <linux/pid_namespace.h>
57#include <linux/device.h>
58#include <linux/kthread.h>
59#include <linux/sched.h>
60#include <linux/signal.h>
56#include <linux/lockdep.h>
57#include <linux/pid_namespace.h>
58#include <linux/device.h>
59#include <linux/kthread.h>
60#include <linux/sched.h>
61#include <linux/signal.h>
62#include <linux/idr.h>
61
62#include <asm/io.h>
63#include <asm/bugs.h>
64#include <asm/setup.h>
65#include <asm/sections.h>
66#include <asm/cacheflush.h>
67
68#ifdef CONFIG_X86_LOCAL_APIC

--- 384 unchanged lines hidden (view full) ---

453static void noinline __init_refok rest_init(void)
454 __releases(kernel_lock)
455{
456 int pid;
457
458 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
459 numa_default_policy();
460 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
63
64#include <asm/io.h>
65#include <asm/bugs.h>
66#include <asm/setup.h>
67#include <asm/sections.h>
68#include <asm/cacheflush.h>
69
70#ifdef CONFIG_X86_LOCAL_APIC

--- 384 unchanged lines hidden (view full) ---

455static void noinline __init_refok rest_init(void)
456 __releases(kernel_lock)
457{
458 int pid;
459
460 kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND);
461 numa_default_policy();
462 pid = kernel_thread(kthreadd, NULL, CLONE_FS | CLONE_FILES);
461 kthreadd_task = find_task_by_pid(pid);
463 kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
462 unlock_kernel();
463
464 /*
465 * The boot idle thread must execute schedule()
466 * at least once to get things moving:
467 */
468 init_idle_bootup_task(current);
469 preempt_enable_no_resched();

--- 67 unchanged lines hidden (view full) ---

537 smp_setup_processor_id();
538
539 /*
540 * Need to run as early as possible, to initialize the
541 * lockdep hash:
542 */
543 unwind_init();
544 lockdep_init();
464 unlock_kernel();
465
466 /*
467 * The boot idle thread must execute schedule()
468 * at least once to get things moving:
469 */
470 init_idle_bootup_task(current);
471 preempt_enable_no_resched();

--- 67 unchanged lines hidden (view full) ---

539 smp_setup_processor_id();
540
541 /*
542 * Need to run as early as possible, to initialize the
543 * lockdep hash:
544 */
545 unwind_init();
546 lockdep_init();
547 debug_objects_early_init();
545 cgroup_init_early();
546
547 local_irq_disable();
548 early_boot_irqs_off();
549 early_init_irq_lock_class();
550
551/*
552 * Interrupts are still disabled. Do necessary setups, then
553 * enable them
554 */
555 lock_kernel();
556 tick_init();
557 boot_cpu_init();
558 page_address_init();
559 printk(KERN_NOTICE);
560 printk(linux_banner);
561 setup_arch(&command_line);
548 cgroup_init_early();
549
550 local_irq_disable();
551 early_boot_irqs_off();
552 early_init_irq_lock_class();
553
554/*
555 * Interrupts are still disabled. Do necessary setups, then
556 * enable them
557 */
558 lock_kernel();
559 tick_init();
560 boot_cpu_init();
561 page_address_init();
562 printk(KERN_NOTICE);
563 printk(linux_banner);
564 setup_arch(&command_line);
565 mm_init_owner(&init_mm, &init_task);
562 setup_command_line(command_line);
563 unwind_setup();
564 setup_per_cpu_areas();
565 setup_nr_cpu_ids();
566 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
567
568 /*
569 * Set up the scheduler prior starting any interrupts (such as the

--- 23 unchanged lines hidden (view full) ---

593 rcu_init();
594 init_IRQ();
595 pidhash_init();
596 init_timers();
597 hrtimers_init();
598 softirq_init();
599 timekeeping_init();
600 time_init();
566 setup_command_line(command_line);
567 unwind_setup();
568 setup_per_cpu_areas();
569 setup_nr_cpu_ids();
570 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
571
572 /*
573 * Set up the scheduler prior starting any interrupts (such as the

--- 23 unchanged lines hidden (view full) ---

597 rcu_init();
598 init_IRQ();
599 pidhash_init();
600 init_timers();
601 hrtimers_init();
602 softirq_init();
603 timekeeping_init();
604 time_init();
605 sched_clock_init();
601 profile_init();
602 if (!irqs_disabled())
603 printk("start_kernel(): bug: interrupts were enabled early\n");
604 early_boot_irqs_on();
605 local_irq_enable();
606
607 /*
608 * HACK ALERT! This is early. We're enabling the console before

--- 22 unchanged lines hidden (view full) ---

631 }
632#endif
633 vfs_caches_init_early();
634 cpuset_init_early();
635 mem_init();
636 enable_debug_pagealloc();
637 cpu_hotplug_init();
638 kmem_cache_init();
606 profile_init();
607 if (!irqs_disabled())
608 printk("start_kernel(): bug: interrupts were enabled early\n");
609 early_boot_irqs_on();
610 local_irq_enable();
611
612 /*
613 * HACK ALERT! This is early. We're enabling the console before

--- 22 unchanged lines hidden (view full) ---

636 }
637#endif
638 vfs_caches_init_early();
639 cpuset_init_early();
640 mem_init();
641 enable_debug_pagealloc();
642 cpu_hotplug_init();
643 kmem_cache_init();
644 debug_objects_mem_init();
645 idr_init_cache();
639 setup_per_cpu_pageset();
640 numa_policy_init();
641 if (late_time_init)
642 late_time_init();
643 calibrate_delay();
644 pidmap_init();
645 pgtable_cache_init();
646 prio_tree_init();

--- 48 unchanged lines hidden (view full) ---

695
696 for (call = __initcall_start; call < __initcall_end; call++) {
697 ktime_t t0, t1, delta;
698 char *msg = NULL;
699 char msgbuf[40];
700 int result;
701
702 if (initcall_debug) {
646 setup_per_cpu_pageset();
647 numa_policy_init();
648 if (late_time_init)
649 late_time_init();
650 calibrate_delay();
651 pidmap_init();
652 pgtable_cache_init();
653 prio_tree_init();

--- 48 unchanged lines hidden (view full) ---

702
703 for (call = __initcall_start; call < __initcall_end; call++) {
704 ktime_t t0, t1, delta;
705 char *msg = NULL;
706 char msgbuf[40];
707 int result;
708
709 if (initcall_debug) {
703 printk("Calling initcall 0x%p", *call);
704 print_fn_descriptor_symbol(": %s()",
710 print_fn_descriptor_symbol("calling %s()\n",
705 (unsigned long) *call);
711 (unsigned long) *call);
706 printk("\n");
707 t0 = ktime_get();
708 }
709
710 result = (*call)();
711
712 if (initcall_debug) {
713 t1 = ktime_get();
714 delta = ktime_sub(t1, t0);
715
712 t0 = ktime_get();
713 }
714
715 result = (*call)();
716
717 if (initcall_debug) {
718 t1 = ktime_get();
719 delta = ktime_sub(t1, t0);
720
716 printk("initcall 0x%p", *call);
717 print_fn_descriptor_symbol(": %s()",
721 print_fn_descriptor_symbol("initcall %s()",
718 (unsigned long) *call);
722 (unsigned long) *call);
719 printk(" returned %d.\n", result);
720
721 printk("initcall 0x%p ran for %Ld msecs: ",
722 *call, (unsigned long long)delta.tv64 >> 20);
723 print_fn_descriptor_symbol("%s()\n",
724 (unsigned long) *call);
723 printk(" returned %d after %Ld msecs\n", result,
724 (unsigned long long) delta.tv64 >> 20);
725 }
726
727 if (result && result != -ENODEV && initcall_debug) {
728 sprintf(msgbuf, "error code %d", result);
729 msg = msgbuf;
730 }
731 if (preempt_count() != count) {
732 msg = "preemption imbalance";
733 preempt_count() = count;
734 }
735 if (irqs_disabled()) {
736 msg = "disabled interrupts";
737 local_irq_enable();
738 }
739 if (msg) {
725 }
726
727 if (result && result != -ENODEV && initcall_debug) {
728 sprintf(msgbuf, "error code %d", result);
729 msg = msgbuf;
730 }
731 if (preempt_count() != count) {
732 msg = "preemption imbalance";
733 preempt_count() = count;
734 }
735 if (irqs_disabled()) {
736 msg = "disabled interrupts";
737 local_irq_enable();
738 }
739 if (msg) {
740 printk(KERN_WARNING "initcall at 0x%p", *call);
741 print_fn_descriptor_symbol(": %s()",
740 print_fn_descriptor_symbol(KERN_WARNING "initcall %s()",
742 (unsigned long) *call);
741 (unsigned long) *call);
743 printk(": returned with %s\n", msg);
742 printk(" returned with %s\n", msg);
744 }
745 }
746
747 /* Make sure there is no pending stuff from the initcall sequence */
748 flush_scheduled_work();
749}
750
751/*

--- 50 unchanged lines hidden (view full) ---

802 numa_default_policy();
803
804 if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
805 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
806
807 (void) sys_dup(0);
808 (void) sys_dup(0);
809
743 }
744 }
745
746 /* Make sure there is no pending stuff from the initcall sequence */
747 flush_scheduled_work();
748}
749
750/*

--- 50 unchanged lines hidden (view full) ---

801 numa_default_policy();
802
803 if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
804 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
805
806 (void) sys_dup(0);
807 (void) sys_dup(0);
808
809 current->signal->flags |= SIGNAL_UNKILLABLE;
810
810 if (ramdisk_execute_command) {
811 run_init_process(ramdisk_execute_command);
812 printk(KERN_WARNING "Failed to execute %s\n",
813 ramdisk_execute_command);
814 }
815
816 /*
817 * We try each of these until one succeeds.

--- 68 unchanged lines hidden ---
811 if (ramdisk_execute_command) {
812 run_init_process(ramdisk_execute_command);
813 printk(KERN_WARNING "Failed to execute %s\n",
814 ramdisk_execute_command);
815 }
816
817 /*
818 * We try each of these until one succeeds.

--- 68 unchanged lines hidden ---