Re: [PATCH v6 2/2] sched: update the rq->avg_idle when a task is moved to an idle CPU

From: Vincent Guittot
Date: Tue Dec 16 2025 - 02:18:23 EST


On Tue, 16 Dec 2025 at 07:22, Shijie Huang
<shijie@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> On 13/12/2025 09:36, Vincent Guittot wrote:
> > put_prev_task_idle() would be a better place to call
> > update_rq_avg_idle() because this is when we leave idle.
>
> The update_rq_avg_idle() is not only called by current CPU, but also
> called by
>
> other CPUs. For example, the try_to_wake_up(), update_rq_avg_idle() is
> called by
>
> the other CPUs. So enqueue_task() is a good place.

But put_prev_task_idle() is called by local CPU whenever it leaves
idle so instead of trying to catch all places that could make the CPU
leave idle it's better to use this single place.
And as you mentioned, put_prev_task_idle is only called by local CPU
whereas enqueue_task can be called by all CPUs creating useless
pressure in the variable.

So I disagree when you say enqueue_task() is a "good place"

Thanks

>
>
> Thanks
>
> Huang Shijie
>