summaryrefslogtreecommitdiff
path: root/kernel/cpu.c
diff options
context:
space:
mode:
authorHuacai Chen <chenhuacai@loongson.cn>2024-06-18 16:13:36 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-07-11 12:49:14 +0200
commit69787793e7f0673465c89714d1522fde978bbfa8 (patch)
treed06676ff5724f7a4e58701ee14c9ff290d06c71b /kernel/cpu.c
parentb0a41715ed23a8cc738327504c656cad745b57da (diff)
downloadlinux-69787793e7f0673465c89714d1522fde978bbfa8.tar.gz
linux-69787793e7f0673465c89714d1522fde978bbfa8.tar.bz2
linux-69787793e7f0673465c89714d1522fde978bbfa8.zip
cpu: Fix broken cmdline "nosmp" and "maxcpus=0"
commit 6ef8eb5125722c241fd60d7b0c872d5c2e5dd4ca upstream. 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'kernel/cpu.c')
-rw-r--r--kernel/cpu.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/kernel/cpu.c b/kernel/cpu.c
index 7ef4bc17453c..874bfb952e6e 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1907,6 +1907,9 @@ static inline bool cpuhp_bringup_cpus_parallel(unsigned int ncpus) { return fals
void __init bringup_nonboot_cpus(unsigned int setup_max_cpus)
{
+ if (!setup_max_cpus)
+ return;
+
/* Try parallel bringup optimization if enabled */
if (cpuhp_bringup_cpus_parallel(setup_max_cpus))
return;