Re: [RFC PATCH v5] sched/fair: select idle cpu from idle cpumask for task wakeup
From: Valentin Schneider
Date:  Mon Dec 07 2020 - 11:53:33 EST
On 07/12/20 15:48, Peter Zijlstra wrote:
> On Wed, Nov 18, 2020 at 12:31:13PM +0800, Aubrey Li wrote:
>> diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
>> index f324dc36fc43..6f5947673e66 100644
>> --- a/kernel/sched/idle.c
>> +++ b/kernel/sched/idle.c
>> @@ -163,6 +163,7 @@ static void cpuidle_idle_call(void)
>>       */
>>
>>      if (cpuidle_not_available(drv, dev)) {
>> +		update_idle_cpumask(this_rq(), true);
>>              tick_nohz_idle_stop_tick();
>>
>>              default_idle_call();
>> @@ -193,6 +194,7 @@ static void cpuidle_idle_call(void)
>>                      max_latency_ns = dev->forced_idle_latency_limit_ns;
>>              }
>>
>> +		update_idle_cpumask(this_rq(), true);
>>              tick_nohz_idle_stop_tick();
>>
>>              next_state = cpuidle_find_deepest_state(drv, dev, max_latency_ns);
>> @@ -205,10 +207,12 @@ static void cpuidle_idle_call(void)
>>               */
>>              next_state = cpuidle_select(drv, dev, &stop_tick);
>>
>> -		if (stop_tick || tick_nohz_tick_stopped())
>> +		if (stop_tick || tick_nohz_tick_stopped()) {
>> +			update_idle_cpumask(this_rq(), true);
>>                      tick_nohz_idle_stop_tick();
>
> We already have a callback in tick_nohz_idle_stop_tick(), namely
> nohz_balance_enter_idle().
That's a no-op for !NO_HZ_COMMON though. For similar reasons, Aubrey moved
the clearing of the cpumask to scheduler_tick().
Are you saying this mechanism should only be driven for NO_HZ kernels? I
would tend to agree with Vincent that this could still be useful for idling
without cutting the tick (!NO_HZ or shallow idle state); see:
  20201124170136.GA26613@vingu-book