From: Vincent Guittot Date: Wed, 8 Oct 2025 13:12:14 +0000 (+0200) Subject: sched/fair: Fix pelt lost idle time detection X-Git-Tag: v5.4.301~56 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d0936c8b0743ae8b88ff3eabd6f0e0f42003ca93;p=thirdparty%2Fkernel%2Fstable.git sched/fair: Fix pelt lost idle time detection [ Upstream commit 17e3e88ed0b6318fde0d1c14df1a804711cab1b5 ] The check for some lost idle pelt time should be always done when pick_next_task_fair() fails to pick a task and not only when we call it from the fair fast-path. The case happens when the last running task on rq is a RT or DL task. When the latter goes to sleep and the /Sum of util_sum of the rq is at the max value, we don't account the lost of idle time whereas we should. Fixes: 67692435c411 ("sched: Rework pick_next_task() slow-path") Signed-off-by: Vincent Guittot Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Sasha Levin --- diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 62c0348ef556..5e8f2167d8ca 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -6978,21 +6978,21 @@ done: __maybe_unused; return p; idle: - if (!rf) - return NULL; - - new_tasks = sched_balance_newidle(rq, rf); + if (rf) { + new_tasks = sched_balance_newidle(rq, rf); - /* - * Because sched_balance_newidle() releases (and re-acquires) rq->lock, it is - * possible for any higher priority task to appear. In that case we - * must re-start the pick_next_entity() loop. - */ - if (new_tasks < 0) - return RETRY_TASK; + /* + * Because sched_balance_newidle() releases (and re-acquires) + * rq->lock, it is possible for any higher priority task to + * appear. In that case we must re-start the pick_next_entity() + * loop. + */ + if (new_tasks < 0) + return RETRY_TASK; - if (new_tasks > 0) - goto again; + if (new_tasks > 0) + goto again; + } /* * rq is about to be idle, check if we need to update the