Re: [RFC PATCH v5] sched/fair: select idle cpu from idle cpumask for task wakeup

From: Peter Zijlstra
Date: Mon Dec 07 2020 - 13:06:26 EST


On Mon, Dec 07, 2020 at 04:52:24PM +0000, Valentin Schneider wrote:
>
> 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?

IFF it keys off of the tick being stopped, then yes. But as said in the
other email, I think that's a very dubious thing to begin with.