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

From: Peter Zijlstra

Date: Wed Nov 12 2025 - 06:21:22 EST


On Wed, Nov 12, 2025 at 04:39:43PM +0530, Shrikanth Hegde wrote:
>
>

> > So perhaps this is the better option -- or did I overlook something with
> > should_we_balance? It doesn't look like that will make a different
> > decision on the retry.
> >
>
> I think in newidle balance, these checks are there in swb to bail of load balance.
> redo logic catches it right?

Urgh, my brain still thinks we're not serializing on newidle. Perhaps I
should make this 2 patches, one moving the serializing and one adding it
to newidle.

> env->dst_rq lock is taken only in attach_tasks, meanwhile, if the wakeup happened,
> pending would be set. is irq enabled or remote CPU can set ttwu_pending on this rq?
>
> if (env->idle == CPU_NEWLY_IDLE) {
> if (env->dst_rq->nr_running > 0 || env->dst_rq->ttwu_pending)
> return 0;
> return 1;
> }

Right, that could get tickled.