From nobody Tue Apr 7 15:28:06 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); } From nobody Tue Apr 7 15:28:06 2026 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 704C33E5ED3 for ; Tue, 3 Mar 2026 11:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772535925; cv=none; b=H3nJ4qdKpLqRLsYyqItu5VB8RUKYpRoipv+6heHKPmJWuFmLcgxWxSGhB9KQavFNI54//brFp7bHGtvx1jD+35MKqahmWk86kfIKpG4dQQq7+4lgSZDNRYchKU+BzKYhzCdDp0PzgordIpSmKF3QZWCCHL63Sm1a0oySmE9nYRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772535925; c=relaxed/simple; bh=Qnv/t+W4ZTEiDjISANsUlcqYS6+xn6PbNkwN213qrh8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=GjjzAQhvtb/zte/EvwWvDYzM0zRQJ/1RaLdRMKrpn/5C+1odPpexaHwqmqizfZ5Jsr9I6nvQZurRfmmRSGQ/98wa/KgG/QuUIIBz8gbSw8k0iILQcmMPT3DYgP7vuLkpIClTDfX9/+w23OGv1+iddDrfDO13gyBsxueUsMj0q5s= 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=S+2ibwnF; arc=none smtp.client-ip=90.155.50.34 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="S+2ibwnF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=ttbCJ8rSOstofOWjXu6KKCoNuH0CTRx+fXGzwHkK+L8=; b=S+2ibwnFF/FNjccUL6TN13inCT oRfR98o1QrTkcDLNmg5nMJe3hadDcpPsGGdkqVhsgxdD8S/3eStgKeI4+1zwDOzGAuQuTOP7oE4hB jM81EVK1Yxs/fu82HIIHvAiSwG77HoiCUbLiASYD2j3Ely73ZQhqgPmSnN1VvOXWiFiRz5G0Z5gBc 01JvRrZN6shtY108UkYLQx8LMaMweheNJdsbJzNPQCZpVyQRAQHE7UiO3Ue7hFicb2oSaU1ncyu5n zpdVqD26EQ3JtHPX0hltYt1gaJJQQh+P2rWcmaaHBvIah6+AXHggb46VgkONxhDhNFMPy1eenQit3 mW+3pejQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxNYu-0000000BNmf-0W6i; Tue, 03 Mar 2026 11:05:12 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 2A5A63031CA; Tue, 03 Mar 2026 12:05:09 +0100 (CET) Message-ID: <20260303110100.004091624@infradead.org> User-Agent: quilt/0.68 Date: Tue, 03 Mar 2026 11:55:41 +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 2/5] x86/topo: Add topology_num_nodes_per_package() 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" Use the MADT and SRAT table data to compute __num_nodes_per_package. Specifically, SRAT has already been parsed in x86_numa_init(), which is cal= led before acpi_boot_init() which parses MADT. So both are available in topology_init_possible_cpus(). This number is useful to divinate the various Intel CoD/SNC and AMD NPS mod= es, since the platforms are failing to provide this otherwise. Doing it this way is independent of the number of online CPUs and other such shenanigans. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Tony Luck Tested-by: K Prateek Nayak Tested-by: Zhang Rui Tested-by: Chen Yu Tested-by: Kyle Meyer --- arch/x86/include/asm/topology.h | 6 ++++++ arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kernel/cpu/topology.c | 13 +++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -155,6 +155,7 @@ extern unsigned int __max_logical_packag extern unsigned int __max_threads_per_core; extern unsigned int __num_threads_per_package; extern unsigned int __num_cores_per_package; +extern unsigned int __num_nodes_per_package; =20 const char *get_topology_cpu_type_name(struct cpuinfo_x86 *c); enum x86_topology_cpu_type get_topology_cpu_type(struct cpuinfo_x86 *c); @@ -179,6 +180,11 @@ static inline unsigned int topology_num_ return __num_threads_per_package; } =20 +static inline unsigned int topology_num_nodes_per_package(void) +{ + return __num_nodes_per_package; +} + #ifdef CONFIG_X86_LOCAL_APIC int topology_get_logical_id(u32 apicid, enum x86_topology_domains at_level= ); #else --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -95,6 +95,9 @@ EXPORT_SYMBOL(__max_dies_per_package); unsigned int __max_logical_packages __ro_after_init =3D 1; EXPORT_SYMBOL(__max_logical_packages); =20 +unsigned int __num_nodes_per_package __ro_after_init =3D 1; +EXPORT_SYMBOL(__num_nodes_per_package); + unsigned int __num_cores_per_package __ro_after_init =3D 1; EXPORT_SYMBOL(__num_cores_per_package); =20 --- a/arch/x86/kernel/cpu/topology.c +++ b/arch/x86/kernel/cpu/topology.c @@ -31,6 +31,7 @@ #include #include #include +#include =20 #include "cpu.h" =20 @@ -492,11 +493,19 @@ void __init topology_init_possible_cpus( set_nr_cpu_ids(allowed); =20 cnta =3D domain_weight(TOPO_PKG_DOMAIN); - cntb =3D domain_weight(TOPO_DIE_DOMAIN); __max_logical_packages =3D cnta; + + pr_info("Max. logical packages: %3u\n", __max_logical_packages); + + cntb =3D num_phys_nodes(); + __num_nodes_per_package =3D DIV_ROUND_UP(cntb, cnta); + + pr_info("Max. logical nodes: %3u\n", cntb); + pr_info("Num. nodes per package:%3u\n", __num_nodes_per_package); + + cntb =3D domain_weight(TOPO_DIE_DOMAIN); __max_dies_per_package =3D 1U << (get_count_order(cntb) - get_count_order= (cnta)); =20 - pr_info("Max. logical packages: %3u\n", cnta); pr_info("Max. logical dies: %3u\n", cntb); pr_info("Max. dies per package: %3u\n", __max_dies_per_package); From nobody Tue Apr 7 15:28:06 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 E5B603E3D95 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=OtCRIIwfeLNlPHGTrs51hwTBcXgcecPAWu2CMkaioU09c7w0+m9+qHFX4uLL3aXi/Eqr4FGy+6tK7wLehvwFfIeuArKigsueMrBfpPcVELibEnXeNcbGoyQEa3xVkpUT0SldOKWVHc1lu8hebV8m4BmPTarmfPdX/kQ6KesTkgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772535921; c=relaxed/simple; bh=F8R+y6/EylwzWzyaxwcTjz6H8iyIl+UOEqaIjVMxc54=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ABYGPEdmt/Og1XldnF5gWpfTYMhdbG0NPV7C1mpa7dZBL6yKjSuQLUClGyxuOmVConnmHgN5oNu572NC/wL9/oNtIDUP9COoKoPJ73+umqyz7u4LmCMleN8DiIZi2oZMCBh7fE/9A68GkRcOS/RclP12Q081a1XgDo3hlhU7DvM= 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=o48TG1Yq; 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="o48TG1Yq" 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=ci91p6pqwet/SKAUe2Pma4oELxRY3XGsVVRNOVEh4+g=; b=o48TG1YqzY0K1NGkrW+ZLGuXAf 7rPLLQIqQdpIKT7DHidX4xM20AD7R9KisWVoDby7WBguu+nHzedvyCfIcCBjorktrJnp5E3d21IIj GYRxowpw24sWmOzeyat2DFjE1X3gNmx5XuuVc38iIB9+IQGh0sOR7XDiGhPK8+hcDJRsN3Pjfr5cR Zr7w0IrfLEEPJEUudQjoXvC3DA/JueJtoAWRXqGNke0MakyIzV2wT8NWhEyMF3w+GCJ+PBZg7bJAj s62KUlDPOMph4MjnxZPcaWHNulpdaYqFV9uSX58vz4oMuKJnr5p9Ze3LvWdkAisPQ25Jbhg7o2DSR y1KHoPZQ==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxNYu-00000002Bz3-19j0; Tue, 03 Mar 2026 11:05:12 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 2E1DB3031E9; Tue, 03 Mar 2026 12:05:09 +0100 (CET) Message-ID: <20260303110100.123701837@infradead.org> User-Agent: quilt/0.68 Date: Tue, 03 Mar 2026 11:55:42 +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 3/5] x86/topo: Replace x86_has_numa_in_package 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" .. with the brand spanking new topology_num_nodes_per_package(). Having the topology setup determine this value during MADT/SRAT parsing bef= ore SMP bringup avoids having to detect this situation when building the SMP topology masks. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Tony Luck Tested-by: K Prateek Nayak Tested-by: Zhang Rui Tested-by: Chen Yu Tested-by: Kyle Meyer --- arch/x86/kernel/smpboot.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -468,13 +468,6 @@ static int x86_cluster_flags(void) } #endif =20 -/* - * Set if a package/die has multiple NUMA nodes inside. - * AMD Magny-Cours, Intel Cluster-on-Die, and Intel - * Sub-NUMA Clustering have this. - */ -static bool x86_has_numa_in_package; - static struct sched_domain_topology_level x86_topology[] =3D { SDTL_INIT(tl_smt_mask, cpu_smt_flags, SMT), #ifdef CONFIG_SCHED_CLUSTER @@ -496,7 +489,7 @@ static void __init build_sched_topology( * PKG domain since the NUMA domains will auto-magically create the * right spanning domains based on the SLIT. */ - if (x86_has_numa_in_package) { + if (topology_num_nodes_per_package() > 1) { unsigned int pkgdom =3D ARRAY_SIZE(x86_topology) - 2; =20 memset(&x86_topology[pkgdom], 0, sizeof(x86_topology[pkgdom])); @@ -550,7 +543,7 @@ int arch_sched_node_distance(int from, i case INTEL_GRANITERAPIDS_X: case INTEL_ATOM_DARKMONT_X: =20 - if (!x86_has_numa_in_package || topology_max_packages() =3D=3D 1 || + if (topology_max_packages() =3D=3D 1 || topology_num_nodes_per_package()= =3D=3D 1 || d < REMOTE_DISTANCE) return d; =20 @@ -606,7 +599,7 @@ void set_cpu_sibling_map(int cpu) o =3D &cpu_data(i); =20 if (match_pkg(c, o) && !topology_same_node(c, o)) - x86_has_numa_in_package =3D true; + WARN_ON_ONCE(topology_num_nodes_per_package() =3D=3D 1); =20 if ((i =3D=3D cpu) || (has_smt && match_smt(c, o))) link_mask(topology_sibling_cpumask, cpu, i); From nobody Tue Apr 7 15:28:06 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 E59BA3DA5C3 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=HabAA7Q+u1dBc8+EWCuMbYV/2EtOpcI28kMG97awkQLxSHQ518TCG9rXPenLjewViaYT4GiNRDrW3wM1b+6tG7il0e//Bpx2uhoN5pydyhDS/Sdje1CLBrBrP1AcGFrb/GbHb2viucpnx99V/JfkGOWl+cU4o8dboIo4zGghWCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772535921; c=relaxed/simple; bh=8+GBbHDnIfsbMDv9zTav96O2Ivvfy6yxI6wJ+le7nmg=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=KhDQA5gWN+ROaTHQL9lff9xGjtDSNy/OmzgAFw6Q89MwfJb092rtwimkZDaQWR02fkzaKtCVho6cQ+bxmUDhvBf8uy0sEuIUMhnUDnci27sXR+I9TkBpaXRSRvDpU3KKoDbeShJ7mGpEdZu6/WiRNVbU62LE0WKd0uFCOVsfPLc= 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=oxNPHXxL; 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="oxNPHXxL" 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=5DnkckvetsDsMJf1bsA1FIpLkc/pUyCpjaeOwgy72kQ=; b=oxNPHXxLlsTdOwY/Ty6G3l89SE 5ZFx6S1O+w6cDKq84PsS6DPgKCTA5NGrxZUoVLxgMHUAKz+11sq0bResWaCkHuO3CrrU7ZeaJkLgH WnHPnbj4KZIE+vBKCi7r6KOqI1NVW8SHzfFnG/nf07LO+Uwmua9fIVrbFd3VhVGQOyovv/kXa3Pw/ HU72OcjSYUbPov6LxsqdOfxe9mQ9IXc63IE9DOOrS1btXQ2joE9youu6z4G2XsyYlzAgIi/bYfULK 94bRtywShgYFTFmPZTWexuMkfC9iOBBKJ5BA9oHOad+04ll2MHZt63QlnK2wd+ckuH2YMlpT1Oqws wCxWVP6g==; 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-00000002Bz2-1Amx; Tue, 03 Mar 2026 11:05:12 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 3302E30325C; Tue, 03 Mar 2026 12:05:09 +0100 (CET) Message-ID: <20260303110100.238361290@infradead.org> User-Agent: quilt/0.68 Date: Tue, 03 Mar 2026 11:55:43 +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 4/5] x86/topo: Fix SNC topology mess 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" Per 4d6dd05d07d0 ("sched/topology: Fix sched domain build error for GNR, CW= F in SNC-3 mode"), the original crazy SNC-3 SLIT table was: node distances: node 0 1 2 3 4 5 0: 10 15 17 21 28 26 1: 15 10 15 23 26 23 2: 17 15 10 26 23 21 3: 21 28 26 10 15 17 4: 23 26 23 15 10 15 5: 26 23 21 17 15 10 And per: https://lore.kernel.org/lkml/20250825075642.GQ3245006@noisy.programming.k= icks-ass.net/ The suggestion was to average the off-trace clusters to restore sanity. However, 4d6dd05d07d0 implements this under various assumptions: - anything GNR/CWF with numa_in_package; - there will never be more than 2 packages; - the off-trace cluster will have distance >20 And then HPE shows up with a machine that matches the Vendor-Family-Model checks but looks like this: Here's an 8 socket (2 chassis) HPE system with SNC enabled: node 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0: 10 12 16 16 16 16 18 18 40 40 40 40 40 40 40 40 1: 12 10 16 16 16 16 18 18 40 40 40 40 40 40 40 40 2: 16 16 10 12 18 18 16 16 40 40 40 40 40 40 40 40 3: 16 16 12 10 18 18 16 16 40 40 40 40 40 40 40 40 4: 16 16 18 18 10 12 16 16 40 40 40 40 40 40 40 40 5: 16 16 18 18 12 10 16 16 40 40 40 40 40 40 40 40 6: 18 18 16 16 16 16 10 12 40 40 40 40 40 40 40 40 7: 18 18 16 16 16 16 12 10 40 40 40 40 40 40 40 40 8: 40 40 40 40 40 40 40 40 10 12 16 16 16 16 18 18 9: 40 40 40 40 40 40 40 40 12 10 16 16 16 16 18 18 10: 40 40 40 40 40 40 40 40 16 16 10 12 18 18 16 16 11: 40 40 40 40 40 40 40 40 16 16 12 10 18 18 16 16 12: 40 40 40 40 40 40 40 40 16 16 18 18 10 12 16 16 13: 40 40 40 40 40 40 40 40 16 16 18 18 12 10 16 16 14: 40 40 40 40 40 40 40 40 18 18 16 16 16 16 10 12 15: 40 40 40 40 40 40 40 40 18 18 16 16 16 16 12 10 10 =3D Same chassis and socket 12 =3D Same chassis and socket (SNC) 16 =3D Same chassis and adjacent socket 18 =3D Same chassis and non-adjacent socket 40 =3D Different chassis Turns out, the 'max 2 packages' thing is only relevant to the SNC-3 parts, = the smaller parts do 8 sockets (like usual). The above SLIT table is sane, but violates the previous assumptions and trips a WARN. Now that the topology code has a sensible measure of nodes-per-package, we = can use that to divinate the SNC mode at hand, and only fix up SNC-3 topologies. There is a 'healthy' amount of paranoia code validating the assumptions on = the SLIT table, a simple pr_err(FW_BUG) print on failure and a fallback to using the regular table. Lets see how long this lasts :-) Fixes: 4d6dd05d07d0 ("sched/topology: Fix sched domain build error for GNR,= CWF in SNC-3 mode") Reported-by: Kyle Meyer 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/kernel/smpboot.c | 185 ++++++++++++++++++++++++++++++++++-------= ----- 1 file changed, 140 insertions(+), 45 deletions(-) --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -506,33 +506,148 @@ static void __init build_sched_topology( } =20 #ifdef CONFIG_NUMA -static int sched_avg_remote_distance; -static int avg_remote_numa_distance(void) +/* + * Test if the on-trace cluster at (N,N) is symmetric. + * Uses upper triangle iteration to avoid obvious duplicates. + */ +static bool slit_cluster_symmetric(int N) { - int i, j; - int distance, nr_remote, total_distance; + int u =3D topology_num_nodes_per_package(); =20 - if (sched_avg_remote_distance > 0) - return sched_avg_remote_distance; + for (int k =3D 0; k < u; k++) { + for (int l =3D k; l < u; l++) { + if (node_distance(N + k, N + l) !=3D + node_distance(N + l, N + k)) + return false; + } + } + + return true; +} + +/* + * Return the package-id of the cluster, or ~0 if indeterminate. + * Each node in the on-trace cluster should have the same package-id. + */ +static u32 slit_cluster_package(int N) +{ + int u =3D topology_num_nodes_per_package(); + u32 pkg_id =3D ~0; + + for (int n =3D 0; n < u; n++) { + const struct cpumask *cpus =3D cpumask_of_node(N + n); + int cpu; + + for_each_cpu(cpu, cpus) { + u32 id =3D topology_logical_package_id(cpu); + if (pkg_id =3D=3D ~0) + pkg_id =3D id; + if (pkg_id !=3D id) + return ~0; + } + } + + return pkg_id; +} + +/* + * Validate the SLIT table is of the form expected for SNC-3, specifically: + * + * - each on-trace cluster should be symmetric, + * - each on-trace cluster should have a unique package-id. + * + * If you NUMA_EMU on top of SNC, you get to keep the pieces. + */ +static bool slit_validate(void) +{ + int u =3D topology_num_nodes_per_package(); + u32 pkg_id, prev_pkg_id =3D ~0; =20 - nr_remote =3D 0; - total_distance =3D 0; - for_each_node_state(i, N_CPU) { - for_each_node_state(j, N_CPU) { - distance =3D node_distance(i, j); - - if (distance >=3D REMOTE_DISTANCE) { - nr_remote++; - total_distance +=3D distance; - } + for (int pkg =3D 0; pkg < topology_max_packages(); pkg++) { + int n =3D pkg * u; + + /* + * Ensure the on-trace cluster is symmetric and each cluster + * has a different package id. + */ + if (!slit_cluster_symmetric(n)) + return false; + pkg_id =3D slit_cluster_package(n); + if (pkg_id =3D=3D ~0) + return false; + if (pkg && pkg_id =3D=3D prev_pkg_id) + return false; + + prev_pkg_id =3D pkg_id; + } + + return true; +} + +/* + * Compute a sanitized SLIT table for SNC; notably SNC-3 can end up with + * asymmetric off-trace clusters, reflecting physical assymmetries. However + * this leads to 'unfortunate' sched_domain configurations. + * + * For example dual socket GNR with SNC-3: + * + * node distances: + * node 0 1 2 3 4 5 + * 0: 10 15 17 21 28 26 + * 1: 15 10 15 23 26 23 + * 2: 17 15 10 26 23 21 + * 3: 21 28 26 10 15 17 + * 4: 23 26 23 15 10 15 + * 5: 26 23 21 17 15 10 + * + * Fix things up by averaging out the off-trace clusters; resulting in: + * + * node 0 1 2 3 4 5 + * 0: 10 15 17 24 24 24 + * 1: 15 10 15 24 24 24 + * 2: 17 15 10 24 24 24 + * 3: 24 24 24 10 15 17 + * 4: 24 24 24 15 10 15 + * 5: 24 24 24 17 15 10 + */ +static int slit_cluster_distance(int i, int j) +{ + static int slit_valid =3D -1; + int u =3D topology_num_nodes_per_package(); + long d =3D 0; + int x, y; + + if (slit_valid < 0) { + slit_valid =3D slit_validate(); + if (!slit_valid) + pr_err(FW_BUG "SLIT table doesn't have the expected form for SNC -- fix= up disabled!\n"); + else + pr_info("Fixing up SNC SLIT table.\n"); + } + + /* + * Is this a unit cluster on the trace? + */ + if ((i / u) =3D=3D (j / u) || !slit_valid) + return node_distance(i, j); + + /* + * Off-trace cluster. + * + * Notably average out the symmetric pair of off-trace clusters to + * ensure the resulting SLIT table is symmetric. + */ + x =3D i - (i % u); + y =3D j - (j % u); + + for (i =3D x; i < x + u; i++) { + for (j =3D y; j < y + u; j++) { + d +=3D node_distance(i, j); + d +=3D node_distance(j, i); } } - if (nr_remote) - sched_avg_remote_distance =3D total_distance / nr_remote; - else - sched_avg_remote_distance =3D REMOTE_DISTANCE; =20 - return sched_avg_remote_distance; + return d / (2*u*u); } =20 int arch_sched_node_distance(int from, int to) @@ -542,34 +657,14 @@ int arch_sched_node_distance(int from, i switch (boot_cpu_data.x86_vfm) { case INTEL_GRANITERAPIDS_X: case INTEL_ATOM_DARKMONT_X: - - if (topology_max_packages() =3D=3D 1 || topology_num_nodes_per_package()= =3D=3D 1 || - d < REMOTE_DISTANCE) + if (topology_max_packages() =3D=3D 1 || + topology_num_nodes_per_package() < 3) return d; =20 /* - * With SNC enabled, there could be too many levels of remote - * NUMA node distances, creating NUMA domain levels - * including local nodes and partial remote nodes. - * - * Trim finer distance tuning for NUMA nodes in remote package - * for the purpose of building sched domains. Group NUMA nodes - * in the remote package in the same sched group. - * Simplify NUMA domains and avoid extra NUMA levels including - * different remote NUMA nodes and local nodes. - * - * GNR and CWF don't expect systems with more than 2 packages - * and more than 2 hops between packages. Single average remote - * distance won't be appropriate if there are more than 2 - * packages as average distance to different remote packages - * could be different. + * Handle SNC-3 asymmetries. */ - WARN_ONCE(topology_max_packages() > 2, - "sched: Expect only up to 2 packages for GNR or CWF, " - "but saw %d packages when building sched domains.", - topology_max_packages()); - - d =3D avg_remote_numa_distance(); + return slit_cluster_distance(from, to); } return d; } From nobody Tue Apr 7 15:28:06 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 E5ADA3E3D94 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=1772535922; cv=none; b=TOCqJuexS5aE4I6ZnIY2KDxqC/Q4hiVVjvSlWGWPZ8NN/APU2zudlQYv+JVWZAaiMpqP7IGFgSDMj6fu4hqhDgi48ukxc8ZsloL/Y6uOK0MS29TjarseOJaXr1fB8OYXKKmrDviTSpcERIdjYUMGJsqDq8F2568Upk+mOXoVfU4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772535922; c=relaxed/simple; bh=LBJb0doU4zjn17XkeyW7lKsnuywpZvQ4WQCVAuT0Zsw=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=tciOKBaGxqn/E3oXPAkVDVkFP2iuBFlVgWpcCcG6d2nchWcK0iRY8iHi02CvxVuS1vQJUadnJ2NfiSk/T5xZgzw4q8KkcfaHIK4BTpNgfsiBRsOMy2GDP915c3pk8eSvhFXOZdBBvRbWSkjn9NjN3NiAndC+f97QuCOqHuvDNJc= 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=jTMtrWEP; 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="jTMtrWEP" 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=6qsTWmBGeTQGIJmUNvz9n8UKNcCP7evNaKscoAxs9FU=; b=jTMtrWEPEjaTfY9fwMosEwYP0Z nafx3oNh8tOd9i2ljrOgNTFzgY32b5NFygqvX7C2Ha29c8gXVEjUCB1PdDSo3PSQlyC3LmhbjoC/d NBOxB9h8pgl+AVwzd2CHjjEj7zOovrO7EGH9HLP4+ilVhN3cIzCwkkUxS7Ny9JaVVMEFpWTf9bIyp Wyjnl0KFRRx+K3bveKuTZJjfzSWAMJDkA78nzKspT/dfFlLnErJnmQrOrkGtGmSdfdQaASk/OJ8Wt B/ILVFvJdMp9lcVQqXKTFVzXQR42Nhy5wJ8PIPejOPSLpT7lLposDqSxskX+k+kR+7zy4ypdaWFTt z4McSHfg==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vxNYu-00000002BzC-3CvL; Tue, 03 Mar 2026 11:05:13 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 370A2303269; Tue, 03 Mar 2026 12:05:09 +0100 (CET) Message-ID: <20260303110100.367976706@infradead.org> User-Agent: quilt/0.68 Date: Tue, 03 Mar 2026 11:55:44 +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 5/5] x86/resctrl: Fix SNC detection 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" From: Tony Luck Now that the x86 topology code has a sensible nodes-per-package measure, that does not depend on the online status of CPUs, use this to divinate the SNC mode. Note that when Cluster on Die (CoD) is configured on older systems this will also show multiple NUMA nodes per package. Intel Resource Director Technology is incomaptible with CoD. Print a warning and do not use the fixup MSR_RMID_SNC_CONFIG. Signed-off-by: Tony Luck Signed-off-by: Peter Zijlstra (Intel) Tested-by: Zhang Rui Tested-by: Chen Yu Link: https://patch.msgid.link/aaCxbbgjL6OZ6VMd@agluck-desk3 --- arch/x86/kernel/cpu/resctrl/monitor.c | 36 ++++-------------------------= ----- 1 file changed, 5 insertions(+), 31 deletions(-) --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -364,7 +364,7 @@ void arch_mon_domain_online(struct rdt_r msr_clear_bit(MSR_RMID_SNC_CONFIG, 0); } =20 -/* CPU models that support MSR_RMID_SNC_CONFIG */ +/* CPU models that support SNC and MSR_RMID_SNC_CONFIG */ static const struct x86_cpu_id snc_cpu_ids[] __initconst =3D { X86_MATCH_VFM(INTEL_ICELAKE_X, 0), X86_MATCH_VFM(INTEL_SAPPHIRERAPIDS_X, 0), @@ -375,40 +375,14 @@ static const struct x86_cpu_id snc_cpu_i {} }; =20 -/* - * There isn't a simple hardware bit that indicates whether a CPU is runni= ng - * in Sub-NUMA Cluster (SNC) mode. Infer the state by comparing the - * number of CPUs sharing the L3 cache with CPU0 to the number of CPUs in - * the same NUMA node as CPU0. - * It is not possible to accurately determine SNC state if the system is - * booted with a maxcpus=3DN parameter. That distorts the ratio of SNC nod= es - * to L3 caches. It will be OK if system is booted with hyperthreading - * disabled (since this doesn't affect the ratio). - */ static __init int snc_get_config(void) { - struct cacheinfo *ci =3D get_cpu_cacheinfo_level(0, RESCTRL_L3_CACHE); - const cpumask_t *node0_cpumask; - int cpus_per_node, cpus_per_l3; - int ret; + int ret =3D topology_num_nodes_per_package(); =20 - if (!x86_match_cpu(snc_cpu_ids) || !ci) + if (ret > 1 && !x86_match_cpu(snc_cpu_ids)) { + pr_warn("CoD enabled system? Resctrl not supported\n"); return 1; - - cpus_read_lock(); - if (num_online_cpus() !=3D num_present_cpus()) - pr_warn("Some CPUs offline, SNC detection may be incorrect\n"); - cpus_read_unlock(); - - node0_cpumask =3D cpumask_of_node(cpu_to_node(0)); - - cpus_per_node =3D cpumask_weight(node0_cpumask); - cpus_per_l3 =3D cpumask_weight(&ci->shared_cpu_map); - - if (!cpus_per_node || !cpus_per_l3) - return 1; - - ret =3D cpus_per_l3 / cpus_per_node; + } =20 /* sanity check: Only valid results are 1, 2, 3, 4, 6 */ switch (ret) {