From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 06D3244CAE3 for ; Fri, 27 Feb 2026 19:23:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772220233; cv=none; b=aGka5yNcurMHT7c9/Zcmp0zafh/AMoNCdR+NlYI++fCVM+48H1JhnKkFqCPRxQ8luAyNByxuiMlFohCK79qGCVG/qAfRd8Wvw00vZOm5o5hoRhOSohc+ypgCoCSEshijIv46SRDmyz5l/pPENt6Y6VAYsRYtqf2yx8mYBd9CN1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772220233; c=relaxed/simple; bh=1ouI10tYa0r2airq6XrgeG8Ry3rguKY/q3g8ABWPH7Y=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=n+Kvp15d8rQhAx3BgsX9F1fLWWoQzJxAqw5vhL3ZT0ds2hydcARMPeiYCqiNVg8qaO0cSojXYl65+NtxGkqpkoy1/GZjfnr8phJN7ClT9WTcoo7+YjxP83m3Y5SFJeNQDycF2E0542mGZvnedU33/ovtCB4BMH62BBQ2j3uvVIY= 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=cHtLBYof; arc=none smtp.client-ip=198.175.65.13 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="cHtLBYof" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1772220231; x=1803756231; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=1ouI10tYa0r2airq6XrgeG8Ry3rguKY/q3g8ABWPH7Y=; b=cHtLBYof6raHPlBDpeBCClpEgrhmj3cXKReotvxJ6gWYbYSZ8slasdmD 0aFNd94zYnip3nC9F8okgaGiQmkUqUsgfGkzfxE6vp5vf2qipyGrr93na /OuUB0ZVklzpLYRsOuT3UIt+y0xD6PIr7JYI+HJqy+NvEkQvZr7V/xE+y RPqKSuE95DkI+O7nhab5hy8qlFyDmU9kNOFDZcfxDcqQ6RdTuwI+gGmE8 g/nPDwZ0VLiGrH0TgxorcX0OmIytuaF6ZPzeapJ0i6ztSWmYc8XQhAP/r cU2VHhv+InH0RReVUERWrPYGbYacSrcnAqe+0D8oWWZ8tB0XiL+l3AOQy Q==; X-CSE-ConnectionGUID: nciR4la9QKKJ9l7mBngRkQ== X-CSE-MsgGUID: 0euXfQXPTHuPPygaPaOEjQ== X-IronPort-AV: E=McAfee;i="6800,10657,11714"; a="84395733" X-IronPort-AV: E=Sophos;i="6.21,314,1763452800"; d="scan'208";a="84395733" Received: from orviesa003.jf.intel.com ([10.64.159.143]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2026 11:23:50 -0800 X-CSE-ConnectionGUID: B32VAiU/RHOiBD70lB3YmQ== X-CSE-MsgGUID: FzgNRZIlQz+M1RrpleDsmA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,314,1763452800"; d="scan'208";a="221131532" Received: from schen9-mobl4.amr.corp.intel.com (HELO [10.125.111.230]) ([10.125.111.230]) by ORVIESA003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2026 11:23:50 -0800 Message-ID: <67cfac6fe0495a533fa3204fa01ee07653029e91.camel@linux.intel.com> Subject: Re: [RFC][PATCH 5/6] x86/topo: Fix SNC topology mess From: Tim Chen To: Peter Zijlstra 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 Date: Fri, 27 Feb 2026 11:23:49 -0800 In-Reply-To: <20260227130130.GD1395266@noisy.programming.kicks-ass.net> References: <20260226104909.675623579@infradead.org> <20260226105052.737712686@infradead.org> <334d4edb-b8f4-41fb-aa16-6cb7abeaa21d@intel.com> <20260227130130.GD1395266@noisy.programming.kicks-ass.net> 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 Fri, 2026-02-27 at 14:01 +0100, Peter Zijlstra wrote: > 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 clu= ster > > has the same package id and give a WARNING if that's not the case. >=20 > 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. >=20 > Is this sufficiently paranoid for you? :-) >=20 Thanks. Looks pretty good and hopefully those warnings will never be triggered. Tim >=20 > --- > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -61,6 +61,7 @@ > #include > #include > #include > +#include > =20 > #include > #include > @@ -506,12 +507,58 @@ static void __init build_sched_topology( > } > =20 > #ifdef CONFIG_NUMA > +static bool slit_cluster_symmetric(int N) > +{ > + for (int k =3D 0; k < __num_nodes_per_package; k++) { > + for (int l =3D k; l < __num_nodes_per_package; l++) { > + if (node_distance(N + k, N + l) !=3D=20 > + node_distance(N + l, N + k)) > + return false; > + } > + } > + > + return true; > +} > + > +static u32 slit_cluster_package(int N) > +{ > + u32 pkg_id =3D ~0; > + > + for (int n =3D 0; n < __num_nodes_per_package; n++) { > + const struct cpumask *cpus =3D cpumask_of_node(N + n); > + int cpu; > + > + for_each_cpu(cpu, cpus) { > + u32 id =3D topology_logical_package_id(cpu); > + if (pkg_id =3D=3D ~0) > + pkg_id =3D id; > + if (pkg_id !=3D 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 =3D slit_cluster_package(0); > + u32 pkg2 =3D slit_cluster_package(__num_nodes_per_package); > + WARN_ON(pkg1 =3D=3D ~0 || pkg2 =3D=3D ~0 || pkg1 =3D=3D 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 =3D __num_nodes_per_package; > long d =3D 0; > int x, y; > =20 > + DO_ONCE_LITE(slit_validate); > + > /* > * Is this a unit cluster on the trace? > */ >=20