From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 849CD38BF70 for ; Thu, 26 Feb 2026 22:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772144731; cv=none; b=kPgmFfac8lJtrd4Op+U6DfHDGBiOyehkp3PX6IY81xNMCP2dQgcAU5aBQj25RENHQzyuuzxijGXT7vuiJree4skkY/a2KNFD2JhG7L5BFpHFCwahqTWf+mWuf1aRalx8qUZVOZNwECTS+r3j4SeUzDqtYbtbtiiIey2hFzydvB8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772144731; c=relaxed/simple; bh=j0zTC3VT2ezLgcMg1jGLbcQw0p9ARr/t8W2N/15Srp4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=G0b0E65DzNOHSLZhPOnrrPzFgdn8eXenXoIjXJaI9Z9ykQb2Hu8zyijUKKuAZFnH7yOe8U9xG8T0sgF09166ZUUu7VDa0JpS1V6XjCdyseTIhQelnuugbZNzUqg+ouNaxhuZNE6yZYtEeuU70PppvvcI3Tjw+AfQkQ0bm8W7iKg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=CIO94A8K; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="CIO94A8K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772144730; x=1803680730; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=j0zTC3VT2ezLgcMg1jGLbcQw0p9ARr/t8W2N/15Srp4=; b=CIO94A8KQyEpwcVvz2B1xq2pg9Z9Zy0dNqENR3nBTdIUaCNkzNGkWWzp ZP2XT/dXlyWUmzPH4LxolsXTPzG8cC4wkT/phBU8EkL2t2f2vQKi96AYw rj9VBXKT8QOk6u+DdQ9gm/vpcuiXbbJLU0m+S20cGlRB4p7gthg1tlEBs aqKg9zIGrEj/APGWW4Rj/aUlGju5syjyyGOlNZp/29ERcL6v4NX4rG/kZ TnCgf5NgQ01rHwMyoytoN/EOmJUcbGXNS4aCYHrFro8K2+/XmgrYH85NU FAtylcjLknBdCj0J0w5+FwaggaeazOBz5p+THVek56ofjDE9TV6/zpAO4 w==; X-CSE-ConnectionGUID: Tr5+hFVBT+6eUvHcHyxJ2Q== X-CSE-MsgGUID: XjGQJpAdT6SKc0s3Saxr/g== X-IronPort-AV: E=McAfee;i="6800,10657,11713"; a="60797735" X-IronPort-AV: E=Sophos;i="6.21,313,1763452800"; d="scan'208";a="60797735" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2026 14:25:30 -0800 X-CSE-ConnectionGUID: 3/lupLLOQx6nvA5Eu6QJrw== X-CSE-MsgGUID: l/pUSSa/SH6xUtEoWxXFKA== X-ExtLoop1: 1 Received: from schen9-mobl4.amr.corp.intel.com (HELO [10.125.111.161]) ([10.125.111.161]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2026 14:25:29 -0800 Message-ID: <20fe9361907864c445c3efd4e8a29d7ba84be6a5.camel@linux.intel.com> Subject: Re: [RFC][PATCH 5/6] x86/topo: Fix SNC topology mess From: Tim Chen To: "Chen, Yu C" , Peter Zijlstra Cc: 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 Date: Thu, 26 Feb 2026 14:25:28 -0800 In-Reply-To: <641cb6457fcbb6509351ecb45bdff300540f9f55.camel@linux.intel.com> References: <20260226104909.675623579@infradead.org> <20260226105052.737712686@infradead.org> <334d4edb-b8f4-41fb-aa16-6cb7abeaa21d@intel.com> <641cb6457fcbb6509351ecb45bdff300540f9f55.camel@linux.intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.1 (3.58.1-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Thu, 2026-02-26 at 14:11 -0800, Tim Chen wrote: > On Thu, 2026-02-26 at 11:00 -0800, Tim Chen wrote: > > On Fri, 2026-02-27 at 01:07 +0800, Chen, Yu C wrote: > > > Hi Peter, > > >=20 > > > On 2/26/2026 6:49 PM, Peter Zijlstra wrote: > > > > + int u =3D __num_nodes_per_package; > > >=20 > > > Yes, this is much simpler, thanks for the patch! > > >=20 > > > > + long d =3D 0; > > > > + int x, y; > > > > + > > > > + /* > > > > + * Is this a unit cluster on the trace? > > > > + */ > > > > + if ((i / u) =3D=3D (j / u)) > > > > + return node_distance(i, j); > > >=20 > > > If the number of nodes per package is 3, we assume that > > > every 3 consecutive nodes are SNC siblings (on the same > > > trace):node0, node1, and node2 are SNC siblings, while > > > node3, node4, and node5 form another group of SNC siblings. > > >=20 > > > I have a curious thought: could it be possible that > > > node0, node2, and node4 are SNC siblings, and node1, > > > node3, and node5 are another set of SNC siblings instead? > > >=20 > > > Then I studied the code a little more, node ids are dynamically > > > allocated via the acpi_map_pxm_to_node, so the assignment of node > > > ids depends on the order in which each processor affinity structure > > > is listed in the SRAT table. For example, suppose CPU0 belongs to > > > package0 and CPU1 belongs to package1, but their entries are placed > > > consecutively in the SRAT. In this case, the Proximity Domain of > > > CPU0 would be mapped to node0 via acpi_map_pxm_to_node, and CPU1=E2= =80=99s > > > Proximity Domain would be assigned node1. The logic above would > > > then treat them as belonging to the same package, even though they > > > are physically in different packages. However, I believe such a > > > scenario is unlikely to occur in practice in the BIOS and if it > > > happens it should be a BIOS bug if I understand correctly. > > >=20 > > >=20 > >=20 > > May be a good idea to sanity check that the nodes in the first unit clu= ster > > has the same package id and give a WARNING if that's not the case. > >=20 > Perhaps something like below >=20 > Tim >=20 > --- > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index d97f8f4e014c..38384ea5253a 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -511,6 +511,24 @@ static int slit_cluster_distance(int i, int j) > int u =3D __num_nodes_per_package; > long d =3D 0; > int x, y; > + static int valid_slit =3D 0; > + > + if (valid_slit =3D=3D -1) > + return node_distance(i, j); > + > + if (valid_slit =3D=3D 0) { > + /* Check first nodes in package are grouped together consecutively */ > + for (x =3D 0; x < u-1 ; x++) { > + if (topology_physical_package_id(x) !=3D > + topology_physical_package_id(x+1)) { This won't work because topology_physical_package_id() takes cpu as argument. Will need to find the first cpu of x and x+1 and pass to it. > + pr_warn("Expect nodes %d and %d to be in the same package", > + x, x+1); > + valid_slit =3D -1; > + return node_distance(i, j); > + } > + } > + valid_slit =3D 1; > + } > =20 > /* > * Is this a unit cluster on the trace? >=20