Re: [RESEND PATCH] sched/fair: Skip sched_balance_running cmpxchg when balance is not due

From: Peter Zijlstra

Date: Tue Oct 14 2025 - 05:26:20 EST


On Tue, Oct 14, 2025 at 12:32:57AM +0800, Chen, Yu C wrote:
> On 10/13/2025 10:26 PM, Peter Zijlstra wrote:
> > On Thu, Oct 02, 2025 at 04:00:12PM -0700, Tim Chen wrote:
> >
> > > During load balancing, balancing at the LLC level and above must be
> > > serialized.
> >
> > I would argue the wording here, there is no *must*, they *are*. Per the
> > current rules SD_NUMA and up get SD_SERIALIZE.
> >
> > This is a *very* old thing, done by Christoph Lameter back when he was
> > at SGI. I'm not sure this default is still valid or not. Someone would
> > have to investigate. An alternative would be moving it into
> > node_reclaim_distance or somesuch.
> >
>
> Do you mean the following:
>
> diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c
> index 444bdfdab731..436c899d8da2 100644
> --- a/kernel/sched/topology.c
> +++ b/kernel/sched/topology.c
> @@ -1697,11 +1697,16 @@ sd_init(struct sched_domain_topology_level *tl,
> sd->cache_nice_tries = 2;
>
> sd->flags &= ~SD_PREFER_SIBLING;
> - sd->flags |= SD_SERIALIZE;
> if (sched_domains_numa_distance[tl->numa_level] >
> node_reclaim_distance) {
> sd->flags &= ~(SD_BALANCE_EXEC |
> SD_BALANCE_FORK |
> SD_WAKE_AFFINE);
> + /*
> + * Nodes that are far away need to be serialized to
> + * reduce the overhead of long-distance task
> migration
> + * caused by load balancing.
> + */
> + sd->flags |= SD_SERIALIZE;
> }
>
> We can launch some tests to see if removing SD_SERIALIZE would
> bring any impact.

Yeah, something like that. But lets first get this other thing sorted. I
agree that the SD_SERIALIZE thing is in the wrong place.