From nobody Tue Apr 7 17:13:52 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) --- 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);