public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sched/fair: Fix pelt lost idle time detection
@ 2025-10-08 13:12 Vincent Guittot
  2025-10-08 14:08 ` Peter Zijlstra
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Vincent Guittot @ 2025-10-08 13:12 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, dietmar.eggemann, rostedt, bsegall,
	mgorman, vschneid, linux-kernel
  Cc: Vincent Guittot

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 <vincent.guittot@linaro.org>
---

I Noticed this while reviewing [1]

[1] https://lore.kernel.org/all/20251006105453.648473106@infradead.org/

 kernel/sched/fair.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b3be1e2749ce..dd0ea01af730 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8920,21 +8920,21 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf
 	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
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2026-01-21 10:14 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-08 13:12 [PATCH] sched/fair: Fix pelt lost idle time detection Vincent Guittot
2025-10-08 14:08 ` Peter Zijlstra
2025-10-14 11:47 ` [tip: sched/urgent] " tip-bot2 for Vincent Guittot
2025-12-02  0:23 ` [PATCH] " Samuel Wu
2025-12-05 15:08   ` Vincent Guittot
2025-12-06  0:54     ` Samuel Wu
2025-12-06  1:20       ` Samuel Wu
2025-12-13  3:54         ` Vincent Guittot
2025-12-23 17:27           ` Qais Yousef
2025-12-23 18:49             ` Qais Yousef
2026-01-05 20:08               ` Samuel Wu
2026-01-12 15:11                 ` Qais Yousef
2026-01-15 23:27                   ` Samuel Wu
2026-01-07  7:54               ` Vincent Guittot
2026-01-07  7:50             ` Vincent Guittot
2026-01-12 15:10               ` Qais Yousef
2026-01-16 14:02                 ` Vincent Guittot
2026-01-16  6:51           ` Alex Hoh (賀振坤)
2026-01-16 14:21             ` Vincent Guittot
2026-01-16 16:13               ` Vincent Guittot
2026-01-20  5:46                 ` Alex Hoh (賀振坤)
2026-01-20  8:36                   ` Vincent Guittot
2026-01-21  1:19                     ` Samuel Wu
2026-01-21 10:14                       ` Vincent Guittot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox