From nobody Tue Apr 7 15:27:24 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 40D52314A9D for ; Thu, 26 Feb 2026 10:53:28 +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=1772103209; cv=none; b=U65pU9EZoPNpFRDT3rTBjkl7CNF0xCvbGJnqyJ2+lgUGxf659gVj0hOzA9DBPRt99Ft4F7efNvb4RT0DvOD3K0WFOgHzRwZwNhSDFhGuykunGHrLba2Y3wrSnkVtRS336tUU/e3PLAlyGg85hPSIIVKggdMzn4TVgf1O6IgmbQI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772103209; c=relaxed/simple; bh=iZAvopNpnUSp8+/yBOyqLS2HmMagn7WqUrLvSZbBZ/E=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=SftgZn10HQ2E/62F6KbvrpK920bJgyNADKjRTxBSTbMpzff+pKFPgx8wIOvYXPQ0WpevCRYgxw23xhle2Bjv+0qIDmTV/Ao9ci6T8ziXrreWWyyzK0LM4lgzL7HGmV83OjV/nB9MyvjP/C9S+YxJ4BYskbUa3qIJgh8Aa+opYIo= 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=lffVtZlE; 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="lffVtZlE" 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=KvQH2wLFPC/Q9x/NS6J+S3uDco8vVpLpqaLkSX0TmGg=; b=lffVtZlEngxDqajsqaN6HBOyOD fV9vd9TCE8esdd2xkYk96kLLuVGpmKGraFVkgOCIlHYqB/EVAShjIbxbhyfIUd1e75xlG6RdxnRAU lYonP7zfFvrstJHBvWUh5hdf6lLPPn61RT1+hlA12YGJ9fQCYv5Gc8mUNYT11RvSUOCT7Euy8vkRE 72v8jlM7+chdkqU1vP4J1iGkZa/bqWP4uPu4ENDszWaK0SnRtASI9lKHJ3IhblTBHBygyg72fJzOR dIObH490yGLjEUAo90iPsM5yNTXogTeeGuOa+ks67HRtwDhSPzXReSoWEMFqxYaAO8QOFqaoaaDjE X+2rLpww==; 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 1vvYzg-0000000AmI7-3Cqr; Thu, 26 Feb 2026 10:53:20 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 0D56C3032E9; Thu, 26 Feb 2026 11:53:19 +0100 (CET) Message-ID: <20260226105052.248382944@infradead.org> User-Agent: quilt/0.68 Date: Thu, 26 Feb 2026 11:49:10 +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 Subject: [RFC][PATCH 1/6] x86/topo: Store extra copy of SRAT table References: <20260226104909.675623579@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" Because numa_emulate() will wreck the __apicid_to_node[] table, keep an extra copy. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Kyle Meyer Tested-by: Tony Luck --- arch/x86/include/asm/numa.h | 5 +++++ arch/x86/mm/numa.c | 4 ++++ 2 files changed, 9 insertions(+) --- a/arch/x86/include/asm/numa.h +++ b/arch/x86/include/asm/numa.h @@ -19,13 +19,18 @@ extern int numa_off; * The mapping may be overridden by apic->numa_cpu_node() on 32bit and thus * should be accessed by the accessors - set_apicid_to_node() and * numa_cpu_node(). + * + * __apicid_to_node[] is affected by numa_emulation(), while + * __apicid_to_phys_node[] is not. */ extern s16 __apicid_to_node[MAX_LOCAL_APIC]; +extern s16 __apicid_to_phys_node[MAX_LOCAL_APIC]; extern nodemask_t numa_nodes_parsed __initdata; =20 static inline void set_apicid_to_node(int apicid, s16 node) { __apicid_to_node[apicid] =3D node; + __apicid_to_phys_node[apicid] =3D node; } =20 extern int numa_cpu_node(int cpu); --- a/arch/x86/mm/numa.c +++ b/arch/x86/mm/numa.c @@ -48,6 +48,10 @@ s16 __apicid_to_node[MAX_LOCAL_APIC] =3D { [0 ... MAX_LOCAL_APIC-1] =3D NUMA_NO_NODE }; =20 +s16 __apicid_to_phys_node[MAX_LOCAL_APIC] =3D { + [0 ... MAX_LOCAL_APIC-1] =3D NUMA_NO_NODE +}; + int numa_cpu_node(int cpu) { u32 apicid =3D early_per_cpu(x86_cpu_to_apicid, cpu); From nobody Tue Apr 7 15:27:24 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 7F61E318EE6 for ; Thu, 26 Feb 2026 10:53:27 +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=1772103209; cv=none; b=WpVzMtWzsmVlzG7bKguj3hnkYh9OxlQ4Sw8ynTkXWdr49s3JYE73cfN6ohSoo3JGLopGVihQq5NAdgQT4GHlXaXTR3mUNqED7EfKlni+Dx2weUa6mbxKq4WXZGEPYoukbTYhwYxipVFqZjG2hLE3w33kT8eKrVv6fXVHyKwrr2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772103209; c=relaxed/simple; bh=hsH/M5tRChuLFKx+9VYKknYGDhNrgjX2gDAqmTZ9HnQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=bF6G/ti+DKg01qa6246ZZiMqEBFuXuw/BXxJOpgvra0wqmbiH3WHvZ6LTgf76z0LzQGEjEcU8bsUBVvVVHKl5GjXp6qmWnfCfPmMji1EA13eNbgNXCw0jLZRUgMqNgJm0iwj878R6Ixg83AzRxmmpQwSsRLWoMDLaUwjVxshNS4= 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=IurmMZ7k; 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="IurmMZ7k" 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=j+kfL6Kla/eHdcwv7oSdE3kNVqFL+qQFrBO9nK/P9UM=; b=IurmMZ7kFcYuIqT/wzgf7CtaQs qzItHXOT9hSpPXyR3Nkn67AVEQjpHkENQUFVhV/l691HdB42EFXmk1z2ZTxP9T1Y1+lKhDUfniknk +HUE6ydkTllJHeJ0pT0m0pa8uwf/15gKdWzKyaH1NsNh2ca71SssQt6hbfi0J7bEArwkPWHp8BVCy JL+H8k4tfWj1wVd3Z2LpR8lpcugMoRPvlC/6Jc8l+63SEda9mZx4ZkmOkkbjPNGrYd5z+Co0+6bQC q54fcjAPfTYI6eZWoUfkYA4RC2iN9HKTEvBNSyTUhnJgvd8VdzuwQZACD7qwVjrjR25iF8/KvqMKW InB7XFfQ==; 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 casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vvYzg-00000002d8R-2RGw; Thu, 26 Feb 2026 10:53:20 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 12659303324; Thu, 26 Feb 2026 11:53:19 +0100 (CET) Message-ID: <20260226105052.355756378@infradead.org> User-Agent: quilt/0.68 Date: Thu, 26 Feb 2026 11:49:11 +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 Subject: [RFC][PATCH 2/6] x86/topo: Add TOPO_NUMA_DOMAIN References: <20260226104909.675623579@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 SRAT data to add an extra NUMA domain. Since the SLIT table is a matrix, the SRAT proximity domain 'must' be a dense set and will not exceed MAX_LOCAL_APIC. Signed-off-by: Peter Zijlstra (Intel) Tested-by: K Prateek Nayak Tested-by: Kyle Meyer Tested-by: Tony Luck --- arch/x86/include/asm/topology.h | 3 +++ arch/x86/kernel/cpu/topology.c | 9 +++++++++ 2 files changed, 12 insertions(+) --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -111,6 +111,9 @@ enum x86_topology_domains { TOPO_DIE_DOMAIN, TOPO_DIEGRP_DOMAIN, TOPO_PKG_DOMAIN, +#ifdef CONFIG_NUMA + TOPO_NUMA_DOMAIN, +#endif TOPO_MAX_DOMAIN, }; =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 @@ -88,6 +89,14 @@ static inline u32 topo_apicid(u32 apicid { if (dom =3D=3D TOPO_SMT_DOMAIN) return apicid; +#ifdef CONFIG_NUMA + if (dom =3D=3D TOPO_NUMA_DOMAIN) { + int nid =3D __apicid_to_phys_node[apicid]; + if (nid =3D=3D NUMA_NO_NODE) + nid =3D 0; + return nid; + } +#endif return apicid & (UINT_MAX << x86_topo_system.dom_shifts[dom - 1]); } From nobody Tue Apr 7 15:27:24 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 7F71A31A7E4 for ; Thu, 26 Feb 2026 10:53:27 +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=1772103210; cv=none; b=Hi/Rcu1FYc9TzbFf24u1LEgtxwk3BDGcIYqIgv9vIA5n1LJFLIDiyqARTgJz9EyYDyeoMjOp+/Jd3lDezX4F65qCpUAgZrtQ6WRaJRgjWnViw58AFc+JihY7rgaM+DLAgQmcC3uEPRxpeIiz33wJLvyjMb0SINq/In9oqRLADC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772103210; c=relaxed/simple; bh=7pbsufB0VpMwdFBqXWZY+zPkB/mCNrM0wLD81BXm7Ag=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=EfykIc4xhi0+A7Weo/AidAuDyBGJO/uMU9uomexPWRZ/+x0iPHRSe4sroU+GIl3Gm1/7XkXS5fmbRLHTsOWapddp3pGo/te8wZGdGMRr9RPtOX8SemRLSEWpoWQR3ztihd+RMLNQPZk+24dijyQBJjnpYg72T5hJeDM+tDSf7W8= 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=RKAfUWzx; 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="RKAfUWzx" 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=5k8B2OzvduTxvI9a29CC0t0j0mDUCFdyxPs9E7lKPis=; b=RKAfUWzxV7AHTDlQ1OiUQK3DnF ajL1AejyeI5IvbdhCcIU2XXhqdQqno1D7V3JTsrbbQLdsAbGvqHWY/VmzRDrbmoxrEail6du2NMTK UsCosTByq5rWXOO2dcsVBp67WfbyhSGi30/G6U0S1fLzjsK1aR3OatN10lmvcWFukyb+dj9lAZwNm K+6UPBoW4IHXIe8IEzoQyLdIBzuQOrM2IpZDHh/glciLu3wBODNgCGFkchLY92/DwPCKDPwZk9kVJ 7h4xXOweoTW5COtnP0ZgnFrmtuphQYealpbsvtStac/9UFqyPz2jJi5YtwMtJOTeRpqYLp91fapaN GBSl4yfw==; 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 1vvYzg-00000002d8Q-2PiV; Thu, 26 Feb 2026 10:53:20 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 17AEF303364; Thu, 26 Feb 2026 11:53:19 +0100 (CET) Message-ID: <20260226105052.472660569@infradead.org> User-Agent: quilt/0.68 Date: Thu, 26 Feb 2026 11:49:12 +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 Subject: [RFC][PATCH 3/6] x86/topo: Add __num_nodes_per_package References: <20260226104909.675623579@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. This number is useful to divinate the various Intel CoD/SNC modes, 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: Kyle Meyer Tested-by: Tony Luck --- arch/x86/include/asm/topology.h | 1 + arch/x86/kernel/cpu/common.c | 3 +++ arch/x86/kernel/cpu/topology.c | 9 ++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) --- a/arch/x86/include/asm/topology.h +++ b/arch/x86/include/asm/topology.h @@ -158,6 +158,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); --- 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 @@ -497,11 +497,18 @@ void __init topology_init_possible_cpus( set_nr_cpu_ids(allowed); =20 cnta =3D domain_weight(TOPO_PKG_DOMAIN); + cntb =3D domain_weight(TOPO_NUMA_DOMAIN); + + __num_nodes_per_package =3D DIV_ROUND_UP(cntb, cnta); + + pr_info("Max. logical packages: %3u\n", 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_logical_packages =3D cnta; __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:27:24 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 993D531AF3D for ; Thu, 26 Feb 2026 10:53:27 +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=1772103209; cv=none; b=XLgM6zcA00OuT9R+/8mJ46IwafiHwqn9KETdY35T4IqukHXO1WCvCVqPqs3rskWCxPMfk1amMEseyS5qmkMjA3PHWjy8iqnKmCHLilOOuzFvz/mGVPTUoYb8Cbt2aY/IKz1Ech6SLdWq6sLXyl49Plqr9b+7r1zI83Isc/4xoW0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772103209; c=relaxed/simple; bh=pt+q/s6e7FsfcomWIi5HdKRWHa1K9dIII7W5M8ySEmA=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=bpFMW79JxoYL2eLFniHZ6yOXJZ5frV7UTChfmdQ/XbSUnH0EMPv+6zM4ZjI5I25lmJkJdJuyrrihPNAXNoH0lgalFmdLadbKkhK3ln/D3189mPCAuQa9s2gYLoYM3UUtRMf745Gfr0s5dCRVPm+fea5R/AmlqbMBjpbap85HyeQ= 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=aZKnGvzf; 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="aZKnGvzf" 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=E8ApyyyRAjhMWtQJ2hxbGXpk9TauzSOAVV8+M36mXTk=; b=aZKnGvzfyWKa/uGaBbLKoAfcw0 zcieSwZPs/jS6c9X8qQeR2ZJi+UslR96BNqYZAr80XlWJFB0hdpVRpmM8dO7P2dhEKlb5pg1SxGP9 vX0+renaT3Fx0uUSDGH4aKGRAmthXV8rq0FjzP6Ktk89/b68+pWH1nPIm4D95DpzFQG84FpWDUe/w RNxPOxeftv+Gqs8mH5KV+FzVA2c8vYNq92mIYRbH0qLBYQ6a7TcYq9h2pc0X+LpEMr4KrWX/qWiRr 27eLt1Oe8hXyM/TYrslzFhKkUN9fdUWgo32wITXEwAAEyWoeTAM6qhALdO6PP0JYD7pepA8Baw4vh g5dzqg9g==; 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 1vvYzg-0000000AmI9-3EIr; Thu, 26 Feb 2026 10:53:21 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 1C64430336E; Thu, 26 Feb 2026 11:53:19 +0100 (CET) Message-ID: <20260226105052.624360500@infradead.org> User-Agent: quilt/0.68 Date: Thu, 26 Feb 2026 11:49:13 +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 Subject: [RFC][PATCH 4/6] x86/topo: Replace x86_has_numa_in_package References: <20260226104909.675623579@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 __num_nodes_per_package. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Kyle Meyer Tested-by: Tony Luck --- 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 (__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 || __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(__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:27:24 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 A30B131B104 for ; Thu, 26 Feb 2026 10:53:27 +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=1772103210; cv=none; b=FPLu+u+cokiIC1/5FDp/WOjr7IAN1KE2erlUBj8v7KiUJ/gvaBLDxvKzk00z52ve9IaVvSVAUtt7pl8B6t73ftcJ+TE+CaFgVKYGXsdAgdHqQM7LCYSFgG8tCAkHMPyB5R6yhHGETUAimRmvHQLj9IGdjY84uGl339xNkPEAhAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772103210; c=relaxed/simple; bh=qoi5WxacZ+5gUX7Wvqj7er0BQYGs4t0EAr6h1bm0b+U=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=cnXeHqFMhe+rtqeXA48yDiT8+WV32ugVWl5YAsYQYkFptW+URKQlW0X7pEDP3dsMKxiIwg6CroyC9INMbtKzMfGaJXhjOIVrfRFUIMVHTiDOUC5LbXxpceRvody1nV3rbwm1RrBJFoGLm6vEGeiDmWS98ef7se4ExUM/2h7NhJU= 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=KmhL1cO6; 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="KmhL1cO6" 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=mpb5TJrEd58y+GogJG8u8vHetBWOc7fxy+EfULdIsOU=; b=KmhL1cO6nXirMNDTI67PAxr+ii GMEPjEu+61LNCJNDU1KJTNqCGwEZ4BjcFc0ztB+o+5UZsZ5NDuQt1O0XHljuyi6tlCgYqLxM2oFPH /sBZx8H0nDDSbR9kKD3GOByYHZ00Acsu37kSKte4Qt6q84tigb0LbrRMoG0aecJF2Hrv/fEK2yfnD iZJ13gx/sNeMXRP2lswH9I2vmRn53zjHRH+6/xXxcTZjX/tNEt8laJWQ5TYAcC4gMFMO78tqmTbxI MN+KoXhVhIDXQwFK0AnM2hyajZ9KWpfP/IToZTiQeX6MNrIifp45R2WdzLcM/KumtJ7TfD2Wtelln LehO+brg==; 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 1vvYzh-0000000AmIT-0szI; Thu, 26 Feb 2026 10:53:21 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 21688303377; Thu, 26 Feb 2026 11:53:19 +0100 (CET) Message-ID: <20260226105052.737712686@infradead.org> User-Agent: quilt/0.68 Date: Thu, 26 Feb 2026 11:49:14 +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 Subject: [RFC][PATCH 5/6] x86/topo: Fix SNC topology mess References: <20260226104909.675623579@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" So per 4d6dd05d07d0 ("sched/topology: Fix sched domain build error for GNR,= CWF 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/ My suggestion was to average the off-trace clusters to restore sanity. However, 4d6dd05d07d0 implements this under various assumptions: - 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 *However* this is SNC-2. This completely invalidates all the earlier assumptions and trips WARNs. 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. With the only assumption that there are no CPU-less nodes -- is this a valid assumption ? Fixes: 4d6dd05d07d0 ("sched/topology: Fix sched domain build error for GNR,= CWF in SNC-3 mode") Signed-off-by: Peter Zijlstra (Intel) Tested-by: Chen Yu Tested-by: Kyle Meyer Tested-by: Tony Luck Tested-by: Zhang Rui --- arch/x86/kernel/smpboot.c | 64 +++++++++++++++++------------------------= ----- 1 file changed, 25 insertions(+), 39 deletions(-) --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -506,33 +506,32 @@ static void __init build_sched_topology( } =20 #ifdef CONFIG_NUMA -static int sched_avg_remote_distance; -static int avg_remote_numa_distance(void) +static int slit_cluster_distance(int i, int j) { - int i, j; - int distance, nr_remote, total_distance; - - if (sched_avg_remote_distance > 0) - return sched_avg_remote_distance; - - 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; - } + int u =3D __num_nodes_per_package; + long d =3D 0; + int x, y; + + /* + * Is this a unit cluster on the trace? + */ + if ((i / u) =3D=3D (j / u)) + return node_distance(i, j); + + /* + * Off-trace cluster, return average of the cluster to force symmetry. + */ + 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,13 +541,11 @@ 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 || __num_nodes_per_package =3D=3D 1= || - d < REMOTE_DISTANCE) + if (topology_max_packages() =3D=3D 1 || __num_nodes_per_package < 3) return d; =20 /* - * With SNC enabled, there could be too many levels of remote + * With SNC-3 enabled, there could be too many levels of remote * NUMA node distances, creating NUMA domain levels * including local nodes and partial remote nodes. * @@ -557,19 +554,8 @@ int arch_sched_node_distance(int from, i * 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. */ - 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:27:24 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 7F6A731A045 for ; Thu, 26 Feb 2026 10:53:27 +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=1772103210; cv=none; b=JWq8HtBxxdycCnWJ4yF6qDCyUhLzFnp4MDMAtmV90uzB49xlU2ULWac1Wsxb0CBpvZHzQI/A81BbBt2Z0aRCN05A8uVPQgxSMNXJSMv9Aq6x4qEJS4N6CUH/iz0FMnoe5hUdzO5ftWWMndDXrwHpbV5VMRr4RIF/EI50OuEoE1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772103210; c=relaxed/simple; bh=kYMJPE6Q2ED9KfhfEexXfbo+LSAH6ZgORYl6fGl/k2w=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=KB3tJTO3UgdwnFjqAbszQV1bT/ccNAZ1rBLpNjLSOweGpKxhgbYIeEgDhoNg94HjXvgG1wemOURnXxxATDXTBwdP7ZSVyGK0Dthk4CDHfvRUckDYQmi47JRJkqdrk/xH2AY9fh4ocK8AzIa3ZxAsRMF8phCKttfkjdsVVDNw/g0= 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=hWfYq5LD; 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="hWfYq5LD" 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=6Ap1gO2VKvV5UsoOPZHflY8h0NOQbPyKmngotMgofi0=; b=hWfYq5LDrGY7GCnxFiyN7K+SYg gcNRT/XfE02CTouP2wwrDXgF9DxVeLlXaATlHcfagDPeAFmNreHeBe1k8v2JZ4UTFRcDUamqL+H9t TTVRDn/sX+poneH4J7exJhHwalMU5IHwXnwtjijAJ7MyS+zmDgiohHnjLe8hqgK6EwIdGzhHQHvcM cAgOVXWtMm6vNrkadkr2SWAzJJqOzJ8DO93SU8efcUYxu51rB2518o05fE0oQeOErGrVAJoDXuZ6R oyFq03teoYibOF95Oxu4g5/iEn7YyQZhQNcKFxaoHXP7qQQh1UUoS7uR0MSRIeZTjwcyh6dgaZwl2 5qSjupCg==; 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 1vvYzh-00000002d8Z-0sOm; Thu, 26 Feb 2026 10:53:21 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 0) id 25348303381; Thu, 26 Feb 2026 11:53:19 +0100 (CET) Message-ID: <20260226105052.852170114@infradead.org> User-Agent: quilt/0.68 Date: Thu, 26 Feb 2026 11:49:15 +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 Subject: [RFC][PATCH 6/6] x86/resctrl: Fix SNC detection References: <20260226104909.675623579@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" 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. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Kyle Meyer Tested-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/monitor.c | 44 -----------------------------= ----- 1 file changed, 1 insertion(+), 43 deletions(-) --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -364,51 +364,9 @@ 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 */ -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), - X86_MATCH_VFM(INTEL_EMERALDRAPIDS_X, 0), - X86_MATCH_VFM(INTEL_GRANITERAPIDS_X, 0), - X86_MATCH_VFM(INTEL_ATOM_CRESTMONT_X, 0), - X86_MATCH_VFM(INTEL_ATOM_DARKMONT_X, 0), - {} -}; - -/* - * 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; - - if (!x86_match_cpu(snc_cpu_ids) || !ci) - 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; + int ret =3D __num_nodes_per_package; =20 /* sanity check: Only valid results are 1, 2, 3, 4, 6 */ switch (ret) {