From mboxrd@z Thu Jan 1 00:00:00 1970 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 A4B6A368947 for ; Fri, 27 Feb 2026 13:01:44 +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=1772197309; cv=none; b=fOEPFuHG7TsjJDW27OWrbxrDCX8YS0jTevqngJgp360zZEHvlwExn+77R/1Gt146pYvyWIgqD9DOpI3lfqfcbKS0Xtq/pct+ikUzKuN0KwzORKjAQNXheCTcEkLiyVhKIQpsY2xI8HWrK+G+W3ot7YQ38DkSfbfp8g6798BeDOM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772197309; c=relaxed/simple; bh=9fmZrICW3+t+prvHOY/RE+0FrmArMUt3YmF6NBjI7Os=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M6AV9t/fqbwSun0rgT/Ytp+veSVAdGDSN4/A2MnRIwY4zDhlsB+6cKYEZZKj8j0ALavXRtrKJapLfAIULOV8hAtzf9w+ncNz9h5c3UXt1e2W+6gh1M3nMAKuSncx5Z70mukviz25ZQ+YEfTod3O7T2gm8Ellq1bmgZYBnqOBnu4= 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=WniRh0BN; 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="WniRh0BN" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=phYuAiEgKk0TOVSwdf46yflfXSgamLM1xiuaZx4hPro=; b=WniRh0BNyx08fwtJCKvfmu9CUg YWB8xH/wKnjXQxgLhoZrrYQOW6na6zV/yf8rxSaQMzAI+9fRUZ3ujsFedmipBhi8/kVaGscz5lyjY H+rW4KwG44HGBkvFDikGn75atZltsbTi83H9ZGIkLLIUeQqrQ3uh1nF7PshEsCpLOm++isBGncf6T M9thENMTxMvj9i1+DyBJjmrarxq8JPsVqGJlCH4pGTYHMKjWWxRdEzrHaNpndlvwKnK06IQIKawlM awrTv+3hlc/0kxoUCNkYkjetLSjmjHNUhhQ98IVHMz8//a1K88KWcjITH3ybXTkob3O5h4fU+mN34 YVeEMRUg==; 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 1vvxTN-00000004aok-0j7K; Fri, 27 Feb 2026 13:01:37 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 7F199300CDE; Fri, 27 Feb 2026 14:01:30 +0100 (CET) Date: Fri, 27 Feb 2026 14:01:30 +0100 From: Peter Zijlstra To: Tim Chen Cc: "Chen, Yu C" , linux-kernel@vger.kernel.org, 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, x86@kernel.org, tglx@kernel.org Subject: Re: [RFC][PATCH 5/6] x86/topo: Fix SNC topology mess Message-ID: <20260227130130.GD1395266@noisy.programming.kicks-ass.net> References: <20260226104909.675623579@infradead.org> <20260226105052.737712686@infradead.org> <334d4edb-b8f4-41fb-aa16-6cb7abeaa21d@intel.com> 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: On Thu, Feb 26, 2026 at 11:00:38AM -0800, Tim Chen wrote: > May be a good idea to sanity check that the nodes in the first unit cluster > has the same package id and give a WARNING if that's not the case. But then we'd also have check the second cluster is another package. And if we're checking that, we might as well check they're symmetric. Is this sufficiently paranoid for you? :-) --- --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c @@ -61,6 +61,7 @@ #include #include #include +#include #include #include @@ -506,12 +507,58 @@ static void __init build_sched_topology( } #ifdef CONFIG_NUMA +static bool slit_cluster_symmetric(int N) +{ + for (int k = 0; k < __num_nodes_per_package; k++) { + for (int l = k; l < __num_nodes_per_package; l++) { + if (node_distance(N + k, N + l) != + node_distance(N + l, N + k)) + return false; + } + } + + return true; +} + +static u32 slit_cluster_package(int N) +{ + u32 pkg_id = ~0; + + for (int n = 0; n < __num_nodes_per_package; n++) { + const struct cpumask *cpus = cpumask_of_node(N + n); + int cpu; + + for_each_cpu(cpu, cpus) { + u32 id = topology_logical_package_id(cpu); + if (pkg_id == ~0) + pkg_id = id; + if (pkg_id != id) + return ~0; + } + } + + return pkg_id; +} + +/* If you NUMA_EMU on top of SNC, you get to keep the pieces */ +static void slit_validate(void) +{ + u32 pkg1 = slit_cluster_package(0); + u32 pkg2 = slit_cluster_package(__num_nodes_per_package); + WARN_ON(pkg1 == ~0 || pkg2 == ~0 || pkg1 == pkg2); + + WARN_ON(!slit_cluster_symmetric(0)); + WARN_ON(!slit_cluster_symmetric(__num_nodes_per_package)); +} + static int slit_cluster_distance(int i, int j) { int u = __num_nodes_per_package; long d = 0; int x, y; + DO_ONCE_LITE(slit_validate); + /* * Is this a unit cluster on the trace? */