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 37ED23B8D73 for ; Wed, 25 Feb 2026 13:36:50 +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=1772026611; cv=none; b=Xye9kKta2RZmTIXXwJvLzGiFCRWI6vo/GuRIo1NY7zoT6U87OTNA89xeD4VY3GIQUpQ7wGrM5RPerFOSGY/5JSGQoMC8HDeyvYCdlLi2YZhNZmNpGCXJMH1K0StrLpPNSpCaVD2FTnmoa0d6TvwpubDB5U1nYEH5ePQjOnfgsqg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772026611; c=relaxed/simple; bh=xgMPr3CfU5Jx0D6Jem8l3Uy77ps9k8tjLQLcjxF2vkI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bWkcplSqI9lRRpRDw+9+A4vb4uo5oRYqsV4P3fhAk7z4u2OexmW8W8MucStgSXwIFE9iBv+PpUa8IY7xELAjeqiVAsnfXiYl7BrpIe5yk+s8tgulGiqBso5nVSBb7FDBhv2K3Mmg722OrFy4Yis4eVeNvPg2v6kwY5u8KjRoUM8= 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=ca6VUpdv; 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="ca6VUpdv" 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=zGzvzbuRQynmnKvbrYpb8Edvua3HrUS5UN05dtpzepE=; b=ca6VUpdvx94NaK711SvFwzoj6Q PV5rARBE8ZvI03GIP/Z+JC4zRlb2gk5JN1Ut9+x/nuBTZ9+YUOP9TftFXDZBs00gDUKmI6Xy+1KL+ 36J6w2Omq2Po/arrgfYOQXecwo305B2kRh2Xaxlsoj3faLzSmTH2ZNc61bldQ41IcWIARjthFrJ3B gYoOudkwQPtB4F3JTYmVCBf4UyYjwWOvwI/ixVcGGf9JeHLRXnvW1F/5ZoCOzXccAl8oKjchZwU2G YMnVZ0YvPYP/0/BmeHpGqZihbjWB+kjNLJAT5UhhIvrxs7JcxyO5h4LTtjdO52WKTp6nXf4NZF/nd pJcayJ9g==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vvF49-000000017LZ-1fwI; Wed, 25 Feb 2026 13:36:37 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 5BEDF3007C4; Wed, 25 Feb 2026 14:36:33 +0100 (CET) Date: Wed, 25 Feb 2026 14:36:33 +0100 From: Peter Zijlstra To: Kyle Meyer Cc: tim.c.chen@linux.intel.com, bp@alien8.de, dave.hansen@linux.intel.com, mingo@redhat.com, tglx@kernel.org, vinicius.gomes@intel.com, brgerst@gmail.com, hpa@zytor.com, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, patryk.wlazlyn@linux.intel.com, rafael.j.wysocki@intel.com, russ.anderson@hpe.com, x86@kernel.org, yu.c.chen@intel.com, zhao1.liu@intel.com Subject: Re: [PATCH v2] sched/topology: Check average distances to remote packages Message-ID: <20260225133633.GW1395416@noisy.programming.kicks-ass.net> References: <20260223170314.GU1395266@noisy.programming.kicks-ass.net> <20260225123052.GN3016024@noisy.programming.kicks-ass.net> 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: <20260225123052.GN3016024@noisy.programming.kicks-ass.net> On Wed, Feb 25, 2026 at 01:30:52PM +0100, Peter Zijlstra wrote: > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index 5cd6950ab672..cba3e4b14250 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -513,33 +513,55 @@ static void __init build_sched_topology(void) > } > > #ifdef CONFIG_NUMA > + > +/* > + * Find the largest symmetric cluster in an attempt to identify the unit size. > + * > + * XXX doesn't respect N_CPU node classes and such. > + */ > +static int slit_cluster_size(void) > { > + int i, j, n, m = num_possible_nodes(); > > + for (n = 2; n < m; n++) { > + for (i = 0; i < n; i++) { > + for (j = i; j < n; j++) { > + if (node_distance(i, j) != node_distance(j, i)) > + return n - 1; > } > } > } > > + return m; > +} If we make x86_has_numa_in_package a counter of how many nodes in the package, we could use that number, rather than trying to guesstimate it. Similarly, if the system would enumerate the SNC mode anywhere, that too could be used. > +static int slit_cluster_distance(int i, int j) > +{ > + static int u = 0; > + long d = 0; > + int x, y; > + > + if (!u) > + u = slit_cluster_size(); > + > + /* > + * Is this a unit cluster on the trace? > + */ > + if ((i / u) == (j / u)) > + return node_distance(i, j); > + > + /* > + * Off-trace cluster, return average of the cluster to force symmetry. > + */ > + x = i - (i % u); > + y = j - (j % u); > + > + for (i = x; i < x + u; i++) { > + for (j = y; j < y + u; j++) > + d += node_distance(i, j); > + } > + > + return d / (u*u); > }