]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xtensa: SMP: limit number of possible CPUs by NR_CPUS
authorMax Filippov <jcmvbkbc@gmail.com>
Sun, 27 Jan 2019 04:35:18 +0000 (20:35 -0800)
committerMax Filippov <jcmvbkbc@gmail.com>
Sun, 27 Jan 2019 18:04:30 +0000 (10:04 -0800)
This fixes the following warning at boot when the kernel is booted on a
board with more CPU cores than was configured in NR_CPUS:

  smp_init_cpus: Core Count = 8
  smp_init_cpus: Core Id = 0
  ------------[ cut here ]------------
  WARNING: CPU: 0 PID: 0 at include/linux/cpumask.h:121 smp_init_cpus+0x54/0x74
  Modules linked in:
  CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc3-00015-g1459333f88a0 #124
  Call Trace:
    __warn$part$3+0x6a/0x7c
    warn_slowpath_null+0x35/0x3c
    smp_init_cpus+0x54/0x74
    setup_arch+0x1c0/0x1d0
    start_kernel+0x44/0x310
    _startup+0x107/0x107

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
arch/xtensa/kernel/smp.c

index 80be6449c497e2ea94f40e196747b6cac01ae557..be1f280c322cd17307e0377736abdb3d955e3ebc 100644 (file)
@@ -96,6 +96,11 @@ void __init smp_init_cpus(void)
        pr_info("%s: Core Count = %d\n", __func__, ncpus);
        pr_info("%s: Core Id = %d\n", __func__, core_id);
 
+       if (ncpus > NR_CPUS) {
+               ncpus = NR_CPUS;
+               pr_info("%s: limiting core count by %d\n", __func__, ncpus);
+       }
+
        for (i = 0; i < ncpus; ++i)
                set_cpu_possible(i, true);
 }