public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Kyle Meyer <kyle.meyer@hpe.com>
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
Date: Wed, 25 Feb 2026 14:36:33 +0100	[thread overview]
Message-ID: <20260225133633.GW1395416@noisy.programming.kicks-ass.net> (raw)
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);
>  }

  reply	other threads:[~2026-02-25 13:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05  0:24 [PATCH v2] sched/topology: Check average distances to remote packages Kyle Meyer
2026-02-23 16:42 ` Kyle Meyer
2026-02-23 17:03 ` Peter Zijlstra
2026-02-25  1:43   ` Kyle Meyer
2026-02-25  9:05     ` Chen, Yu C
2026-02-25 12:30     ` Peter Zijlstra
2026-02-25 13:36       ` Peter Zijlstra [this message]
2026-02-25 15:39       ` Chen, Yu C
2026-02-25 15:44         ` Peter Zijlstra
2026-02-25 16:32           ` Peter Zijlstra
2026-02-25 16:40             ` Peter Zijlstra
2026-02-25 21:37             ` Tim Chen
2026-02-25 22:30               ` Peter Zijlstra
2026-02-25 22:54                 ` Peter Zijlstra
2026-02-25 22:55                 ` Tim Chen
2026-02-25 23:29                   ` Kyle Meyer
2026-02-26 18:14                     ` Tim Chen
2026-02-25 16:41       ` Kyle Meyer
2026-02-25 16:49         ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260225133633.GW1395416@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kprateek.nayak@amd.com \
    --cc=kyle.meyer@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=patryk.wlazlyn@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=russ.anderson@hpe.com \
    --cc=tglx@kernel.org \
    --cc=tim.c.chen@linux.intel.com \
    --cc=vinicius.gomes@intel.com \
    --cc=x86@kernel.org \
    --cc=yu.c.chen@intel.com \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox