Re: [RFC PATCH 4/6] sched/fair: Restrict newidle balance to LLC domain

From: Li kunyu

Date: Tue Oct 27 2026 - 22:17:10 EST




On 2026/10/21 20:42, Peter Zijlstra wrote:
> On Tue, Oct 20, 2026 at 04:37:44PM +0800, Li kunyu wrote:
>
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 6e2271484c86..f2bf4b53d8a9 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -14983,6 +14983,24 @@ static inline bool nohz_idle_balance(struct rq *this_rq, enum cpu_idle_type idle
>> static inline void nohz_newidle_balance(struct rq *this_rq) { }
>> #endif /* !CONFIG_NO_HZ_COMMON */
>>
>> +/*
>> + * is_smt_buddy_newidle_constrain - After enabling the smt_buddy_assist
>> + * feature, check whether the current
>> + * scheduling domain meets the conditions
>> + * for skipping statistics.
>> + * @sd: The current scheduling domain that is to be traversed.
>> + */
>> +static bool is_smt_buddy_newidle_constrain(struct sched_domain *sd)
>> +{
>> + if (!sched_feat(SMT_BUDDY_ASSIST))
>> + return false;
>> +
>> + if (sd->flags & SD_NUMA)
>> + return true;
>> +
>> + return false;
>> +}
>> +
>> /*
>> * sched_balance_newidle is called by schedule() if this_cpu is about to become
>> * idle. Attempts to pull tasks from other CPUs.
>> @@ -15080,7 +15098,8 @@ static int sched_balance_newidle(struct rq *this_rq, struct rq_flags *rf)
>> weight = (1024 + weight/2) / weight;
>> }
>>
>> - pulled_task = sched_balance_rq(this_cpu, this_rq,
>> + if (!is_smt_buddy_newidle_constrain(sd))
>> + pulled_task = sched_balance_rq(this_cpu, this_rq,
>> sd, CPU_NEWLY_IDLE,
>> &continue_balancing,
>> false);
> You could have just fiddled with SD_BALANCE_NEWIDLE, no? But instead you
> went and did something inscrutable and violated coding style *again*.
> Any multi-line block must have {} on.

I would like to get your opinion on modifying patch 4 (I have also consulted
Tim). Please take a look at the following:

1. If relax_domain_level is set, patch4 is disabled.

2. If relax_domain_level is not set and the feature is enabled, patch4 takes effect.


--
thanks,
kunyu