Re: [PATCH 2/4] sched/fair: Small cleanup to sched_balance_newidle()
From: Vincent Guittot
Date: Fri Nov 14 2025 - 05:23:02 EST
On Fri, 14 Nov 2025 at 10:49, Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Wed, Nov 12, 2025 at 08:58:23PM +0530, Shrikanth Hegde wrote:
>
> > > @@ -12865,6 +12869,8 @@ static int sched_balance_newidle(struct
> > > if (!cpu_active(this_cpu))
> > > return 0;
> > > + __sched_balance_update_blocked_averages(this_rq);
> > > +
> >
> > is this done only when sd == null ?
>
> Its done always.
>
> > > /*
> > > * This is OK, because current is on_cpu, which avoids it being picked
> > > * for load-balance and preemption/IRQs are still disabled avoiding
> > > @@ -12891,7 +12897,6 @@ static int sched_balance_newidle(struct
> > > raw_spin_rq_unlock(this_rq);
> > > t0 = sched_clock_cpu(this_cpu);
> > > - sched_balance_update_blocked_averages(this_cpu);
> > > rcu_read_lock();
> > > for_each_domain(this_cpu, sd) {
> >
> > Referring to commit,
> > 9d783c8dd112a (sched/fair: Skip update_blocked_averages if we are defering load balance)
> > I think vincent added the max_newidle_lb_cost check since sched_balance_update_blocked_averages is costly.
>
> That seems to suggest we only should do
> sched_balance_update_blocked_averages() when we're going to do
> balancing and so skipping when !sd is fine.
sched_balance_update_blocked_averages() can be costly so we want to
include it in the sd->max_idle_balance_cost so we skip newidle lb and
update blocked load if avg_idle is shorter than doin the update and
the newidle lb of the 1st level
when sd is null we should still skip
sched_balance_update_blocked_averages() is its cost is higher than
avg_idle but it seems that we don't.
>
>