Re: [PATCH 1/2] sched: force update of blocked load of idle cpus

From: Brendan Jackman
Date: Fri Nov 10 2017 - 09:53:24 EST



Hi Todd,

On Thu, Nov 09 2017 at 19:56, Todd Kjos wrote:
>> @@ -8683,6 +8692,10 @@ static void nohz_balancer_kick(void)
>>
>> if (test_and_set_bit(NOHZ_BALANCE_KICK, nohz_flags(ilb_cpu)))
>> return;
>> +
>> + if (only_update)
>> + set_bit(NOHZ_STATS_KICK, nohz_flags(ilb_cpu));
>
> Should there be an "else clear_bit(NOHZ_STATS_KICK, nohz_flags(ilb_cpu));" ?
>
> Seems like any time this is called as !only_update, we should stop
> inhibiting rebalance. In fact, we should perhaps go a little further
> so that an only_update never inhibits rebalance from a concurrent
> !only_update.

Yes, I think you are essentially right. To make sure I understand you: I
guess you are saying that where two CPUs are concurrently in
nohz_balancer_kick, one with only_update=1 and one with only_update=0,
the former should not prevent the latter from triggering a full load
balance. (I'm assuming they both get the same value for ilb_cpu).

The exact solution you described won't work: only one of those CPUs can
get to this line of code, because of the test_and_set_bit above. So I
think we need something like:

if (test_and_set_bit(NOHZ_BALANCE_KICK, nohz_flags(ilb_cpu))) {
if (!only_update) {
/*
* There's a pending stats kick or an ongoing
* nohz_idle balance that's just for stats.
* Convert it to a proper nohz balance.
*/
clear_bit(NOHZ_STATS_KICK, nohz_flags(ilb_cpu));
}
return;
}

if (only_update)
set_bit(NOHZ_STATS_KICK, nohz_flags(ilb_cpu));

There's still scope for some lost rebalance_domains calls, but as
Vincent pointed out in a recent chat, because the rq->next_balance
fields won't be changed for the CPUs they get missed out, those will
only be delayed until the next scheduler_tick.

I'm on holiday ATM, I'll get to testing that when I get back.

Thanks for the review,
Brendan