MIPS: Support hard limit of cpu count (nr_cpu_ids)
authorHuacai Chen <[email protected]>
Thu, 26 Jun 2014 03:41:25 +0000 (11:41 +0800)
committerRalf Baechle <[email protected]>
Wed, 30 Jul 2014 19:44:46 +0000 (21:44 +0200)
On MIPS currently, only the soft limit of cpu count (maxcpus) has its
effect, this patch enable the hard limit (nr_cpus) as well. Processor
cores which greater than maxcpus and less than nr_cpus can be taken up
via cpu hotplug. The code is borrowed from X86.

Signed-off-by: Huacai Chen <[email protected]>
Reviewed-by: Andreas Herrmann <[email protected]>
Cc: John Crispin <[email protected]>
Cc: Steven J. Hill <[email protected]>
Cc: Aurelien Jarno <[email protected]>
Cc: [email protected]
Cc: Fuxin Zhang <[email protected]>
Cc: Zhangjin Wu <[email protected]>
Patchwork: https://patchwork.linux-mips.org/patch/7183/
Signed-off-by: Ralf Baechle <[email protected]>
arch/mips/kernel/setup.c

index a842154d57dc466eaba000039b3fd5e436c6cb69..2f01201b158cd353abc0d8b5cee5c6b376bc6772 100644 (file)
@@ -729,6 +729,25 @@ static void __init resource_init(void)
        }
 }
 
+#ifdef CONFIG_SMP
+static void __init prefill_possible_map(void)
+{
+       int i, possible = num_possible_cpus();
+
+       if (possible > nr_cpu_ids)
+               possible = nr_cpu_ids;
+
+       for (i = 0; i < possible; i++)
+               set_cpu_possible(i, true);
+       for (; i < NR_CPUS; i++)
+               set_cpu_possible(i, false);
+
+       nr_cpu_ids = possible;
+}
+#else
+static inline void prefill_possible_map(void) {}
+#endif
+
 void __init setup_arch(char **cmdline_p)
 {
        cpu_probe();
@@ -752,6 +771,7 @@ void __init setup_arch(char **cmdline_p)
 
        resource_init();
        plat_smp_setup();
+       prefill_possible_map();
 
        cpu_cache_init();
 }