Re: [PATCH v4] sched/fair: do not scan twice in detach_tasks()

From: Shijie Huang
Date: Mon Jul 21 2025 - 23:18:30 EST



On 2025/7/21 17:40, Vincent Guittot wrote:
On Mon, 21 Jul 2025 at 04:40, Huang Shijie
<shijie@xxxxxxxxxxxxxxxxxxxxxx> wrote:
detach_tasks() uses struct lb_env.loop_max as an env.src_rq->cfs_tasks
iteration count limit. It is however set without the source RQ lock held,
and besides detach_tasks() can be re-invoked after releasing and
re-acquiring the RQ lock per LBF_NEED_BREAK.

This means that env.loop_max and the actual length of env.src_rq->cfs_tasks
as observed within detach_tasks() can differ. This can cause some tasks to
why not setting env.loop_max only once rq lock is taken in this case ?

Yes.  we do it in this way.


Thanks

Huang Shijie