Re: [PATCH v6 2/2] sched: update the rq->avg_idle when a task is moved to an idle CPU
From: Shijie Huang
Date: Mon Dec 15 2025 - 04:36:11 EST
On 12/12/2025 22:22, Dietmar Eggemann wrote:
sched_change uses dequeue_task()/enqueue_task() for a queued task toSo you could move (1) back to (2) avoiding the 'if rq->idle_stamp' forCould you please tell me what is "avoiding the 'if rq->idle_stamp' for
the sched_change pattern for instance?
the sched_change pattern" ?
Sorry, I do not understand your meaning.
change prio, policy, sched params, taskgroups, etc.
For sched_change, the dequeue_task()/enqueue_task() only work when
the queued task has TASK_ON_RQ_QUEUED flags. The TASK_ON_RQ_QUEUED
is set in activate_task().
1.) For this active task, if the sched_change makes it dequeue_task()/enqueue_task() on
current CPU, it's okay. Since current CPU is not in the newidle, the "rq->idle_stamp" is 0 at this case.
This patch works fine.
2.) For this active task, if the sched_change makes it dequeue_task()/enqueue_task() on an another CPU,
it's okay too.
2.1) If the another CPU's idle_stamp is 0, the another CPU is busy now.
The sched_change works fine with this patch.
2.2) If the another CPU's idle_stamp is not 0, the sched_change also works fine with this patch.
Since the sched_change is breaking the idle state of the another CPU by moving an active
task to an idle CPU. It makes sense.
Thanks
Huang Shijie