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