]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - init/main.c
[PATCH] more for_each_cpu() conversions
[mirror_ubuntu-bionic-kernel.git] / init / main.c
index 4c194c47395f9b7c06fc4dd713d920eadcd2f757..9cf6b307bfd7dde1d63698ee5976eede3cd5c124 100644 (file)
@@ -333,6 +333,7 @@ static void __init setup_per_cpu_areas(void)
 {
        unsigned long size, i;
        char *ptr;
+       unsigned long nr_possible_cpus = num_possible_cpus();
 
        /* Copy section for each CPU (we discard the original) */
        size = ALIGN(__per_cpu_end - __per_cpu_start, SMP_CACHE_BYTES);
@@ -340,12 +341,16 @@ static void __init setup_per_cpu_areas(void)
        if (size < PERCPU_ENOUGH_ROOM)
                size = PERCPU_ENOUGH_ROOM;
 #endif
+       ptr = alloc_bootmem(size * nr_possible_cpus);
 
-       ptr = alloc_bootmem(size * NR_CPUS);
-
-       for (i = 0; i < NR_CPUS; i++, ptr += size) {
+       for (i = 0; i < NR_CPUS; i++) {
+               if (!cpu_possible(i)) {
+                       __per_cpu_offset[i] = (char*)0 - __per_cpu_start;
+                       continue;
+               }
                __per_cpu_offset[i] = ptr - __per_cpu_start;
                memcpy(ptr, __per_cpu_start, __per_cpu_end - __per_cpu_start);
+               ptr += size;
        }
 }
 #endif /* !__GENERIC_PER_CPU */
@@ -438,6 +443,15 @@ void __init parse_early_param(void)
  *     Activate the first processor.
  */
 
+static void __init boot_cpu_init(void)
+{
+       int cpu = smp_processor_id();
+       /* Mark the boot cpu "present", "online" etc for SMP and UP case */
+       cpu_set(cpu, cpu_online_map);
+       cpu_set(cpu, cpu_present_map);
+       cpu_set(cpu, cpu_possible_map);
+}
+
 asmlinkage void __init start_kernel(void)
 {
        char * command_line;
@@ -447,17 +461,13 @@ asmlinkage void __init start_kernel(void)
  * enable them
  */
        lock_kernel();
+       boot_cpu_init();
        page_address_init();
        printk(KERN_NOTICE);
        printk(linux_banner);
        setup_arch(&command_line);
        setup_per_cpu_areas();
-
-       /*
-        * Mark the boot cpu "online" so that it can call console drivers in
-        * printk() and can access its per-cpu storage.
-        */
-       smp_prepare_boot_cpu();
+       smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
 
        /*
         * Set up the scheduler prior starting any interrupts (such as the