]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cpu: Fix broken cmdline "nosmp" and "maxcpus=0"
authorHuacai Chen <chenhuacai@loongson.cn>
Tue, 18 Jun 2024 08:13:36 +0000 (16:13 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 23 Jun 2024 18:04:14 +0000 (20:04 +0200)
After the rework of "Parallel CPU bringup", the cmdline "nosmp" and
"maxcpus=0" parameters are not working anymore. These parameters set
setup_max_cpus to zero and that's handed to bringup_nonboot_cpus().

The code there does a decrement before checking for zero, which brings it
into the negative space and brings up all CPUs.

Add a zero check at the beginning of the function to prevent this.

[ tglx: Massaged change log ]

Fixes: 18415f33e2ac4ab382 ("cpu/hotplug: Allow "parallel" bringup up to CPUHP_BP_KICK_AP_STATE")
Fixes: 06c6796e0304234da6 ("cpu/hotplug: Fix off by one in cpuhp_bringup_mask()")
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240618081336.3996825-1-chenhuacai@loongson.cn
kernel/cpu.c

index 74cfdb66a9bdd259d0a9659e9c041681f1cba8d7..3d2bf1d50a0c4a5608a48173ee9deea3758b4b50 100644 (file)
@@ -1859,6 +1859,9 @@ static inline bool cpuhp_bringup_cpus_parallel(unsigned int ncpus) { return fals
 
 void __init bringup_nonboot_cpus(unsigned int max_cpus)
 {
+       if (!max_cpus)
+               return;
+
        /* Try parallel bringup optimization if enabled */
        if (cpuhp_bringup_cpus_parallel(max_cpus))
                return;