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