mirror of
https://github.com/torvalds/linux.git
synced 2026-09-12 20:53:03 +02:00
sched/core: Skip rq->avg_idle update without a valid idle_stamp
Commit4b603f1551("sched: Update rq->avg_idle when a task is moved to an idle CPU") moved rq->avg_idle accounting out of the wakeup path and into put_prev_task_idle(), so that the idle interval is consumed whenever the idle task is switched out. The wakeup-side accounting that it replaced only updated rq->avg_idle when rq->idle_stamp was non-zero. The new helper lost that validity check and unconditionally computes: rq_clock(rq) - rq->idle_stamp If rq->idle_stamp is zero, this uses rq_clock(rq) as the sample. That is not a valid idle duration and can immediately drive rq->avg_idle to its clamp. This can happen when sched_balance_newidle() returns before setting rq->idle_stamp, for example when this_rq->ttwu_pending is set. In that case the rq can switch to the idle task with idle_stamp still zero and leave idle again when the pending wakeup is processed. Other paths can also switch to the idle task without setting rq->idle_stamp via newidle_balance(), for example find_proxy_task() or force-idling. Restore the idle_stamp validity check in update_rq_avg_idle() and skip the rq->avg_idle update when there is no measured idle interval. Fixes:4b603f1551("sched: Update rq->avg_idle when a task is moved to an idle CPU") Signed-off-by: Shubhang Kaushik (Ampere) <sh@gentwo.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: K Prateek Nayak <kprateek.nayak@amd.com> Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org> Acked-by: John Stultz <jstultz@google.com> Link: https://patch.msgid.link/20260807-master-v3-1-c328354efed3@gentwo.org
This commit is contained in:
parent
dae5c02920
commit
c6dcd97c8b
|
|
@ -3742,11 +3742,17 @@ static inline void ttwu_do_wakeup(struct task_struct *p)
|
|||
|
||||
void update_rq_avg_idle(struct rq *rq)
|
||||
{
|
||||
u64 delta = rq_clock(rq) - rq->idle_stamp;
|
||||
u64 max = 2*rq->max_idle_balance_cost;
|
||||
u64 idle_stamp = rq->idle_stamp;
|
||||
u64 delta, max;
|
||||
|
||||
if (!idle_stamp)
|
||||
return;
|
||||
|
||||
delta = rq_clock(rq) - idle_stamp;
|
||||
|
||||
update_avg(&rq->avg_idle, delta);
|
||||
|
||||
max = 2 * rq->max_idle_balance_cost;
|
||||
if (rq->avg_idle > max)
|
||||
rq->avg_idle = max;
|
||||
rq->idle_stamp = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user