From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) (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 6F9D7332607 for ; Thu, 26 Feb 2026 17:46:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.147.86 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772128018; cv=none; b=CyBB3wmdmrLG69hOUCMMvJZ9X3xVguhWJkfuOLvfo0dtir/OcgQtk4Tm5/cuQVJHdDC5vedEg5Ttddjs30hRdPyAeWa4u15u1PbOqyMTbzni7SnSWto4N+EeVEbDUfHOznsO5p/h4fZlyaUU4xF8WRjfb6wv/fMln6GT89aRAZQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772128018; c=relaxed/simple; bh=lA43vHUvjk7HmNqybQTZyRNr05x7j7MApJiGEq3xMQA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WPlC/pOnobabuI7kQykK5tS54LBiqIOzqFipVWW2tY6pwk8riI4KoGSbr7TiU15IIr/wbQzRTLSGTsd725GzR2NhfIXPJe9QupoiQsyRVgknpvGz9bZudyZYpSi2+gc1mhqJto673l4R2zU5eIXX23uwBgxMHJf5jAaCpKQDTQE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=hpe.com; spf=pass smtp.mailfrom=hpe.com; dkim=pass (2048-bit key) header.d=hpe.com header.i=@hpe.com header.b=itDanaD7; arc=none smtp.client-ip=148.163.147.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=hpe.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hpe.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=hpe.com header.i=@hpe.com header.b="itDanaD7" Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61QEqOgx995850; Thu, 26 Feb 2026 17:46:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pps0720; bh=h/znYsLscD7Gni9BAN14SYyUuk +8gJCKyfXdrGpJCFo=; b=itDanaD7UJ8noANyeFq7WCC5EYKHsD6d6BIsuIG//t L9fqyUhbEt+Pvwrs1y2NNQLzEVgzUW69wAWTPDVqJ84XG6zIaQDxNVdrog35xKhC crKrSK3qdj5KlLsNqTUDSDlADIYHwGPPl9oASvRSeHIjLgofxsdAZLRQDPiAVA+H RByvbmdd4/684kUUiT3w3UYzWLq5GJvap0Kg81ENjIM2LR/T9+hRkfprzyS25Ko9 vdHYlqBdveSrfeOmND6XzuitVRpj6qaVEqCjQB7RBj9o1SFZoP4wEbebkz4ZVKgQ +Z7gSjCdZH9lnWgKwgrSrBMjSfcEMicNA1Kujp5pVXjw== Received: from p1lg14881.it.hpe.com (p1lg14881.it.hpe.com [16.230.97.202]) by mx0a-002e3701.pphosted.com (PPS) with ESMTPS id 4cjrakas9r-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 26 Feb 2026 17:46:21 +0000 (GMT) Received: from p1lg14886.dc01.its.hpecorp.net (unknown [10.119.18.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by p1lg14881.it.hpe.com (Postfix) with ESMTPS id 2D187808047; Thu, 26 Feb 2026 17:46:21 +0000 (UTC) Received: from HPE-5CG20646DK.localdomain (unknown [16.231.227.36]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by p1lg14886.dc01.its.hpecorp.net (Postfix) with ESMTPS id E073080173D; Thu, 26 Feb 2026 17:46:19 +0000 (UTC) Date: Thu, 26 Feb 2026 11:46:15 -0600 From: Kyle Meyer To: Peter Zijlstra Cc: x86@kernel.org, tglx@kernel.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, yu.c.chen@intel.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: Re: [RFC][PATCH 3/6] x86/topo: Add __num_nodes_per_package Message-ID: References: <20260226104909.675623579@infradead.org> <20260226105052.472660569@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260226105052.472660569@infradead.org> X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjI2MDE2MSBTYWx0ZWRfX4KleUDRJ3LF5 OhD3Dk5fHNF9BH2TahyLuOOxdaL+zCfC1aC6w3s6JxMinvJYciPS1627i0XFIEkmbOnsIbxTTPY hGDP22+JGUU9mrfJnIHsXMcUCKdK6+G+atWFuEJTgnR/2pwQi6WdaGMATOWAvpS+IVLzS94t4vB ejlNv/0taY4IHc+hJvCzswrHvN/0U3HexhtOYinzRGEK8KQhAjUiVr/ZN/719M0dLl94puJlawL YIIA2PHz3g6owpIzdzdUy0f1nW9tAZbsouU/aMTfCj8BpRo+r/0LGm4fiy+aITDQYL9GdC10TYR RSI5C49vblcG+ciY3GZG2NaQObmDJdY4i4ot8AVH5NW9xOfcCj9EL+x65sWc8h7lI8gQQz5ujcq Y7IAcVeWSSBTePzOaU22rNf7SL220fL+jnSIDBRI7tOvZUszimpE61KA1SqgqT7XQDvluLLYjEZ 19ybXqVYaDIUIFtfDnQ== X-Authority-Analysis: v=2.4 cv=TfmbdBQh c=1 sm=1 tr=0 ts=69a086ed cx=c_pps a=FAnPgvRYq/vnBSvlTDCQOQ==:117 a=FAnPgvRYq/vnBSvlTDCQOQ==:17 a=kj9zAlcOel0A:10 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=JfrnYn6hAAAA:8 a=XTVyYjMxx5Q1UAFu-78A:9 a=CjuIK1q_8ugA:10 a=1CNFftbPRP8L7MoqJWF3:22 X-Proofpoint-ORIG-GUID: f7q3KpK-PLuHFunTdgDt-CzEuBhWDonU X-Proofpoint-GUID: f7q3KpK-PLuHFunTdgDt-CzEuBhWDonU X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-26_02,2026-02-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 impostorscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602260161 On Thu, Feb 26, 2026 at 11:49:12AM +0100, Peter Zijlstra wrote: > 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; > > 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 = 1; > EXPORT_SYMBOL(__max_logical_packages); > > +unsigned int __num_nodes_per_package __ro_after_init = 1; > +EXPORT_SYMBOL(__num_nodes_per_package); > + > unsigned int __num_cores_per_package __ro_after_init = 1; > EXPORT_SYMBOL(__num_cores_per_package); > > --- 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); > > cnta = domain_weight(TOPO_PKG_DOMAIN); > + cntb = domain_weight(TOPO_NUMA_DOMAIN); We'll need to check CONFIG_NUMA here. TOPO_NUMA_DOMAIN is undeclared when CONFIG_NUMA is not set. > + > + __num_nodes_per_package = 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 = domain_weight(TOPO_DIE_DOMAIN); > __max_logical_packages = cnta; > __max_dies_per_package = 1U << (get_count_order(cntb) - get_count_order(cnta)); > > - 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); > > >