Re: [RFC PATCH] sched/fair: Choose the CPU where short task is running during wake up

From: Chen Yu
Date: Fri Sep 30 2022 - 12:06:58 EST


On 2022-09-29 at 14:59:46 +0800, Honglei Wang wrote:
> > > > @@ -6050,7 +6063,8 @@ wake_affine_idle(int this_cpu, int prev_cpu, int sync)
> > > > if (available_idle_cpu(this_cpu) && cpus_share_cache(this_cpu, prev_cpu))
> > > > return available_idle_cpu(prev_cpu) ? prev_cpu : this_cpu;
> > > > - if (sync && cpu_rq(this_cpu)->nr_running == 1)
> > > > + if ((sync && cpu_rq(this_cpu)->nr_running == 1) ||
> > > > + is_short_task(cpu_curr(this_cpu)))
>
> Seems it a bit breaks idle (or will be idle) purpose of wake_affine_idle()
> here.
Exactly, we should prefer previous idle CPU to 'potential idle' this_cpu to keep
it consistent.
> Maybe we can do it something like this?
>
> if ((sync || is_short_task(cpu_curr(this_cpu))) &&
> cpu_rq(this_cpu)->nr_running == 1)
>
Yes, Prateek's experimental results has proven your suggestion.

thanks,
Chenyu
> Thanks,
> Honglei