From nobody Tue Apr 7 17:13:52 2026 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 E5A4B3E3D93 for ; Tue, 3 Mar 2026 11:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772535921; cv=none; b=E192K5p0MSC8pn6hIEeq+O+l2sneRCRMpNPnGSNci3ZhxUtu3Xfjua1hk44hS6qYHuW9GVia5bAZzIW77n2v2IbEK1wvn/hPmKJYp1/sT1xyGe6+qiFgqR0h2V3Ej3RCzU3msL3dNT3RCKDvG+ace1PeYqbbqYubUviU7cV9L6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772535921; c=relaxed/simple; bh=OQn3+HNs/wrrQtIFNu+fgDY3GVFUc7A8c0TbFhKA8TE=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=p/NpStZ5Al7EO/3ZiHLQg56Jfpk7hqRWriNCW4SIOpGi9baXjg1WOMxxnrmsk0PUZ4znVBXQg2k0ITfvZNvnH8nyWb0kUxOz/ehTZspeqKA4QqOUYgYxxfutcnJtruxfq+Hx42u20ZVWpx2t5ZtBUKIhVYx0HpX1Gp43yq72i5A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=NcOPFfWB; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="NcOPFfWB" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=zmSaS7m/6iDa44+p+q2dWLgsIAkPt7bN3Pg4Vk5FKgQ=; b=NcOPFfWBI9Y1yK3mVbEYltq2W3 e/ngmMj/Gkt9Ml7sCafYNFlzyYHolHG8l9TjPmSpm36n0I+qTuE2nseagYIMHq3JR2+IbCE1XXl+Z bhh/hDjMlyhphya1DWZcFpcEmNV05yVO1S0OZsipeBU7lhWR0PosRYcooK9O0HJunko2jSmb2Vgc7 Csh8pxR73TZOUkS0NQb15CyP9oCofEU0ssJxGJrZqcyn/bwwTtRB0XRrWBpHD5rIfLRdlzrJYXf4s magSdJj97wvFBDD49zkE+vs1Jp7rHA+F4rCa6gNIIl/p04OLhIOelokEbAu5V2nSdK4U0DEjlJlFi DAfFy3tQ==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxNYu-00000002Bz1-1An9; Tue, 03 Mar 2026 11:05:12 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 25AAA300FB6; Tue, 03 Mar 2026 12:05:09 +0100 (CET) Message-ID: <20260303110059.889884023@infradead.org> User-Agent: quilt/0.68 Date: Tue, 03 Mar 2026 11:55:40 +0100 From: Peter Zijlstra To: x86@kernel.org, tglx@kernel.org Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, tim.c.chen@linux.intel.com, yu.c.chen@intel.com, kyle.meyer@hpe.com, vinicius.gomes@intel.com, brgerst@gmail.com, hpa@zytor.com, kprateek.nayak@amd.com, patryk.wlazlyn@linux.intel.com, rafael.j.wysocki@intel.com, russ.anderson@hpe.com, zhao1.liu@intel.com, tony.luck@intel.com, Zhang Rui Subject: [PATCH v2 1/5] x86/numa: Store extra copy of numa_nodes_parsed References: <20260303105539.428037056@infradead.org> 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 Content-Type: text/plain; charset="utf-8" The topology setup code needs to know the total number of physical nodes enumerated in SRAT; however NUMA_EMU can cause the existing numa_nodes_parsed bitmap to be fictitious. Therefore, keep a copy of the bitmap specifically to retain the physical node count. Suggested-by: K Prateek Nayak Signed-off-by: Peter Zijlstra (Intel) Tested-by: K Prateek Nayak Tested-by: Zhang Rui Tested-by: Chen Yu Tested-by: Kyle Meyer --- arch/x86/include/asm/numa.h | 6 ++++++ arch/x86/kernel/cpu/topology.c | 1 + arch/x86/mm/numa.c | 8 ++++++++ arch/x86/mm/srat.c | 2 ++ 4 files changed, 17 insertions(+) --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -22,6 +22,7 @@ extern int numa_off; */ extern s16 __apicid_to_node[MAX_LOCAL_APIC]; extern nodemask_t numa_nodes_parsed __initdata; +extern nodemask_t numa_phys_nodes_parsed __initdata; =20 static inline void set_apicid_to_node(int apicid, s16 node) { @@ -48,6 +49,7 @@ extern void __init init_cpu_to_node(void extern void numa_add_cpu(unsigned int cpu); extern void numa_remove_cpu(unsigned int cpu); extern void init_gi_nodes(void); +extern int num_phys_nodes(void); #else /* CONFIG_NUMA */ static inline void numa_set_node(int cpu, int node) { } static inline void numa_clear_node(int cpu) { } @@ -55,6 +57,10 @@ static inline void init_cpu_to_node(void static inline void numa_add_cpu(unsigned int cpu) { } static inline void numa_remove_cpu(unsigned int cpu) { } static inline void init_gi_nodes(void) { } +static inline int num_phys_nodes(void) +{ + return 1; +} #endif /* CONFIG_NUMA */ =20 #ifdef CONFIG_DEBUG_PER_CPU_MAPS --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -48,6 +48,8 @@ s16 __apicid_to_node[MAX_LOCAL_APIC] =3D { [0 ... MAX_LOCAL_APIC-1] =3D NUMA_NO_NODE }; =20 +nodemask_t numa_phys_nodes_parsed __initdata; + int numa_cpu_node(int cpu) { u32 apicid =3D early_per_cpu(x86_cpu_to_apicid, cpu); @@ -57,6 +59,11 @@ int numa_cpu_node(int cpu) return NUMA_NO_NODE; } =20 +int __init num_phys_nodes(void) +{ + return bitmap_weight(numa_phys_nodes_parsed.bits, MAX_NUMNODES); +} + cpumask_var_t node_to_cpumask_map[MAX_NUMNODES]; EXPORT_SYMBOL(node_to_cpumask_map); =20 @@ -210,6 +217,7 @@ static int __init dummy_numa_init(void) 0LLU, PFN_PHYS(max_pfn) - 1); =20 node_set(0, numa_nodes_parsed); + node_set(0, numa_phys_nodes_parsed); numa_add_memblk(0, 0, PFN_PHYS(max_pfn)); =20 return 0; --- a/arch/x86/mm/srat.c +++ b/arch/x86/mm/srat.c @@ -57,6 +57,7 @@ acpi_numa_x2apic_affinity_init(struct ac } set_apicid_to_node(apic_id, node); node_set(node, numa_nodes_parsed); + node_set(node, numa_phys_nodes_parsed); pr_debug("SRAT: PXM %u -> APIC 0x%04x -> Node %u\n", pxm, apic_id, node); } =20 @@ -97,6 +98,7 @@ acpi_numa_processor_affinity_init(struct =20 set_apicid_to_node(apic_id, node); node_set(node, numa_nodes_parsed); + node_set(node, numa_phys_nodes_parsed); pr_debug("SRAT: PXM %u -> APIC 0x%02x -> Node %u\n", pxm, apic_id, node); }