xen: compilation fix fo xen CPU hotplugging
[safe/jmp/linux-2.6] / init / main.c
index a87d4ca..3e17a3b 100644 (file)
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/initrd.h>
-#include <linux/hdreg.h>
 #include <linux/bootmem.h>
 #include <linux/tty.h>
 #include <linux/gfp.h>
 #include <linux/percpu.h>
 #include <linux/kmod.h>
+#include <linux/vmalloc.h>
 #include <linux/kernel_stat.h>
 #include <linux/start_kernel.h>
 #include <linux/security.h>
+#include <linux/smp.h>
 #include <linux/workqueue.h>
 #include <linux/profile.h>
 #include <linux/rcupdate.h>
@@ -60,6 +61,7 @@
 #include <linux/sched.h>
 #include <linux/signal.h>
 #include <linux/idr.h>
+#include <linux/ftrace.h>
 
 #include <asm/io.h>
 #include <asm/bugs.h>
@@ -86,8 +88,6 @@ extern void init_IRQ(void);
 extern void fork_init(unsigned long);
 extern void mca_init(void);
 extern void sbus_init(void);
-extern void pidhash_init(void);
-extern void pidmap_init(void);
 extern void prio_tree_init(void);
 extern void radix_tree_init(void);
 extern void free_initmem(void);
@@ -414,6 +414,13 @@ static void __init smp_init(void)
 {
        unsigned int cpu;
 
+       /*
+        * Set up the current CPU as possible to migrate to.
+        * The other ones will be done by cpu_up/cpu_down()
+        */
+       cpu = smp_processor_id();
+       cpu_set(cpu, cpu_active_map);
+
        /* FIXME: This should be done in userspace --RR */
        for_each_present_cpu(cpu) {
                if (num_online_cpus() >= setup_max_cpus)
@@ -602,6 +609,7 @@ asmlinkage void __init start_kernel(void)
        softirq_init();
        timekeeping_init();
        time_init();
+       sched_clock_init();
        profile_init();
        if (!irqs_disabled())
                printk("start_kernel(): bug: interrupts were enabled early\n");
@@ -628,12 +636,15 @@ asmlinkage void __init start_kernel(void)
 
 #ifdef CONFIG_BLK_DEV_INITRD
        if (initrd_start && !initrd_below_start_ok &&
-                       initrd_start < min_low_pfn << PAGE_SHIFT) {
+           page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {
                printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
-                   "disabling it.\n",initrd_start,min_low_pfn << PAGE_SHIFT);
+                   "disabling it.\n",
+                   page_to_pfn(virt_to_page((void *)initrd_start)),
+                   min_low_pfn);
                initrd_start = 0;
        }
 #endif
+       vmalloc_init();
        vfs_caches_init_early();
        cpuset_init_early();
        mem_init();
@@ -679,11 +690,13 @@ asmlinkage void __init start_kernel(void)
 
        acpi_early_init(); /* before LAPIC and SMP init */
 
+       ftrace_init();
+
        /* Do the rest non-__init'ed, we're now alive */
        rest_init();
 }
 
-static int __initdata initcall_debug;
+static int initcall_debug;
 
 static int __init initcall_debug_setup(char *str)
 {
@@ -692,55 +705,59 @@ static int __init initcall_debug_setup(char *str)
 }
 __setup("initcall_debug", initcall_debug_setup);
 
-extern initcall_t __initcall_start[], __initcall_end[];
-
-static void __init do_initcalls(void)
+int do_one_initcall(initcall_t fn)
 {
-       initcall_t *call;
        int count = preempt_count();
+       ktime_t delta;
+       char msgbuf[64];
+       struct boot_trace it;
+
+       if (initcall_debug) {
+               it.caller = task_pid_nr(current);
+               printk("calling  %pF @ %i\n", fn, it.caller);
+               it.calltime = ktime_get();
+       }
 
-       for (call = __initcall_start; call < __initcall_end; call++) {
-               ktime_t t0, t1, delta;
-               char *msg = NULL;
-               char msgbuf[40];
-               int result;
+       it.result = fn();
 
-               if (initcall_debug) {
-                       print_fn_descriptor_symbol("calling  %s()\n",
-                                       (unsigned long) *call);
-                       t0 = ktime_get();
-               }
-
-               result = (*call)();
+       if (initcall_debug) {
+               it.rettime = ktime_get();
+               delta = ktime_sub(it.rettime, it.calltime);
+               it.duration = (unsigned long long) delta.tv64 >> 10;
+               printk("initcall %pF returned %d after %Ld usecs\n", fn,
+                       it.result, it.duration);
+               trace_boot(&it, fn);
+       }
 
-               if (initcall_debug) {
-                       t1 = ktime_get();
-                       delta = ktime_sub(t1, t0);
+       msgbuf[0] = 0;
 
-                       print_fn_descriptor_symbol("initcall %s()",
-                                       (unsigned long) *call);
-                       printk(" returned %d after %Ld msecs\n", result,
-                               (unsigned long long) delta.tv64 >> 20);
-               }
+       if (it.result && it.result != -ENODEV && initcall_debug)
+               sprintf(msgbuf, "error code %d ", it.result);
 
-               if (result && result != -ENODEV && initcall_debug) {
-                       sprintf(msgbuf, "error code %d", result);
-                       msg = msgbuf;
-               }
-               if (preempt_count() != count) {
-                       msg = "preemption imbalance";
-                       preempt_count() = count;
-               }
-               if (irqs_disabled()) {
-                       msg = "disabled interrupts";
-                       local_irq_enable();
-               }
-               if (msg) {
-                       print_fn_descriptor_symbol(KERN_WARNING "initcall %s()",
-                                       (unsigned long) *call);
-                       printk(" returned with %s\n", msg);
-               }
+       if (preempt_count() != count) {
+               strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
+               preempt_count() = count;
+       }
+       if (irqs_disabled()) {
+               strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
+               local_irq_enable();
        }
+       if (msgbuf[0]) {
+               printk("initcall %pF returned with %s\n", fn, msgbuf);
+       }
+
+       return it.result;
+}
+
+
+extern initcall_t __initcall_start[], __initcall_end[], __early_initcall_end[];
+
+static void __init do_initcalls(void)
+{
+       initcall_t *call;
+
+       for (call = __early_initcall_end; call < __initcall_end; call++)
+               do_one_initcall(*call);
 
        /* Make sure there is no pending stuff from the initcall sequence */
        flush_scheduled_work();
@@ -755,6 +772,7 @@ static void __init do_initcalls(void)
  */
 static void __init do_basic_setup(void)
 {
+       rcu_init_sched(); /* needed by module_init stage. */
        /* drivers will send hotplug events */
        init_workqueues();
        usermodehelper_init();
@@ -763,23 +781,12 @@ static void __init do_basic_setup(void)
        do_initcalls();
 }
 
-static int __initdata nosoftlockup;
-
-static int __init nosoftlockup_setup(char *str)
-{
-       nosoftlockup = 1;
-       return 1;
-}
-__setup("nosoftlockup", nosoftlockup_setup);
-
 static void __init do_pre_smp_initcalls(void)
 {
-       extern int spawn_ksoftirqd(void);
+       initcall_t *call;
 
-       migration_init();
-       spawn_ksoftirqd();
-       if (!nosoftlockup)
-               spawn_softlockup_task();
+       for (call = __initcall_start; call < __early_initcall_end; call++)
+               do_one_initcall(*call);
 }
 
 static void run_init_process(char *init_filename)
@@ -854,6 +861,7 @@ static int __init kernel_init(void * unused)
        smp_prepare_cpus(setup_max_cpus);
 
        do_pre_smp_initcalls();
+       start_boot_trace();
 
        smp_init();
        sched_init_smp();
@@ -880,6 +888,7 @@ static int __init kernel_init(void * unused)
         * we're essentially up and running. Get rid of the
         * initmem segments and start the user-mode stuff..
         */
+       stop_boot_trace();
        init_post();
        return 0;
 }