From nobody Wed Jun 17 04:20:17 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 326933CBE80 for ; Wed, 22 Apr 2026 09:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776851926; cv=none; b=qN27gMVAV1fW5Upk3rce8W6i738pwXa68SjmKnaSBWraz90bFPs/Ohj1dYzk9KwQRF+6SlIFF57Nt9LzHqLY2mqdEVEt8b9b87Sa3ZkI9wmK7sw9zP6uQfYg+ZkxLtVmFzoSvqGTeymlJlkc4O1bT+UgZtu2Feo0QcOJDxVGN9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776851926; c=relaxed/simple; bh=Xg/jBmhstlc+ZQQereWP1P4U6klc7SJJSsk+aeJxPMU=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=e+tn+whC7yP+F3Rb6sNNZnKlSGj0yITyyv8bDyVlfGY1gT6H6u/0pElcbFxLXoxnLricoijfbeePUfvkZhrJXwHGfnOr9sJM88zM3DULseNn9A3OJujZWRxkWsyA3adfb9npE2mhDwi2ssKNdPzFDqmmILWoYGs/u18Qhr3BFSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=TBXFRhCn; arc=none smtp.client-ip=113.46.200.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="TBXFRhCn" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=KzG7QVIK5yv7fWAWvRb7Qe0WGjsIK4KIw8WxnQ1m/wg=; b=TBXFRhCn3vDzNvumDZ+tzrNu5Uawfe48uLVgCB8TbKWR52dvlRYTnOHBnlvOMbcikpIfVTy19 u3LwlZzhxYyMVD4TdESAT9MFHbDSQVYd90ClsKqduXLPWKpSuSL0RCtS7B7jLiVdSyYCE/s3Uf+ rCYLrb/tj03+l5zD5gj21Bc= Received: from mail.maildlp.com (unknown [172.19.163.214]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4g0vdt6bhgznTVg; Wed, 22 Apr 2026 17:52:18 +0800 (CST) Received: from kwepemr200004.china.huawei.com (unknown [7.202.195.241]) by mail.maildlp.com (Postfix) with ESMTPS id CBBBC4056C; Wed, 22 Apr 2026 17:58:32 +0800 (CST) Received: from huawei.com (10.50.163.32) by kwepemr200004.china.huawei.com (7.202.195.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Wed, 22 Apr 2026 17:58:32 +0800 From: Pengjie Zhang To: , CC: , , , , , , , , , , , , , , Subject: [PATCH] arm64: smp: Limit nr_cpu_ids under nosmp Date: Wed, 22 Apr 2026 17:58:31 +0800 Message-ID: <20260422095831.2926775-1-zhangpengjie2@huawei.com> X-Mailer: git-send-email 2.33.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemr200004.china.huawei.com (7.202.195.241) Content-Type: text/plain; charset="utf-8" Under nosmp (maxcpus=3D0), arm64 never brings up secondary CPUs. However, arm64 still enumerates firmware-described CPUs during SMP initialization, so secondary CPUs can remain visible to for_each_possible_cpu() users even though they never reach the bringup path in this configuration. This is not just a cosmetic mask mismatch: code iterating over possible CPUs may observe secondary CPU per-CPU state that is never fully initialized under nosmp. Limit nr_cpu_ids to 1 in arch_disable_smp_support() so that secondary CPUs are not set up on arm64 when nosmp/maxcpus=3D0 is in effect. Signed-off-by: Pengjie Zhang --- arch/arm64/kernel/smp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 1aa324104afb..cc34c68871e9 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -435,6 +435,15 @@ static void __init hyp_mode_check(void) } } =20 +void __init arch_disable_smp_support(void) +{ + /* + * Under nosmp/maxcpus=3D0, only the boot CPU can ever be brought up. + * Limit nr_cpu_ids so that secondary CPUs are never set up. + */ + set_nr_cpu_ids(1); +} + void __init smp_cpus_done(unsigned int max_cpus) { pr_info("SMP: Total of %d processors activated.\n", num_online_cpus()); --=20 2.33.0