public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] sched/fair: Only increment deadline once on yield
@ 2025-09-11  9:51 Fernand Sieber
  2025-09-11 11:03 ` Alexander Graf
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Fernand Sieber @ 2025-09-11  9:51 UTC (permalink / raw)
  To: mingo, peterz, vincent.guittot, juri.lelli
  Cc: dietmar.eggemann, bsegall, graf, wangtao554, tanghui20,
	zhangqiao22, linux-kernel, nh-open-source, Madadi Vineeth Reddy

If a task yields, the scheduler may decide to pick it again. The task in
turn may decide to yield immediately or shortly after, leading to a tight
loop of yields.

If there's another runnable task as this point, the deadline will be
increased by the slice at each loop. This can cause the deadline to runaway
pretty quickly, and subsequent elevated run delays later on as the task
doesn't get picked again. The reason the scheduler can pick the same task
again and again despite its deadline increasing is because it may be the
only eligible task at that point.

Fix this by updating the deadline only to one slice ahead.

Note, we might want to consider iterating on the implementation of yield as
follow up:
* the yielding task could be forfeiting its remaining slice by
  incrementing its vruntime correspondingly
* in case of yield_to the yielding task could be donating its remaining
  slice to the target task

Fixes: 147f3efaa24182 ("sched/fair: Implement an EEVDF-like scheduling  policy")
Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Fernand Sieber <sieberf@amazon.com>
Link: https://lore.kernel.org/r/20250401123622.584018-1-sieberf@amazon.com
---
Resending it with no code changes.
Adding "fixes" tag as per Alex's suggestion on thread.
Adding a few more scheduler folks.
---
 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index b173a059315c..d6a0d22d08d7 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8921,7 +8921,7 @@ static void yield_task_fair(struct rq *rq)
 	 */
 	rq_clock_skip_update(rq);

-	se->deadline += calc_delta_fair(se->slice, se);
+	se->deadline = se->vruntime + calc_delta_fair(se->slice, se);
 }

 static bool yield_to_task_fair(struct rq *rq, struct task_struct *p)
--
2.43.0




Amazon Development Centre (South Africa) (Proprietary) Limited
29 Gogosoa Street, Observatory, Cape Town, Western Cape, 7925, South Africa
Registration Number: 2004 / 034463 / 07


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

end of thread, other threads:[~2025-11-05  9:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11  9:51 [PATCH RESEND] sched/fair: Only increment deadline once on yield Fernand Sieber
2025-09-11 11:03 ` Alexander Graf
2025-09-11 11:37 ` Peter Zijlstra
2025-09-11 13:56   ` Peter Zijlstra
2025-09-16 13:35   ` Fernand Sieber
2025-09-16 14:02 ` [PATCH v2] sched/fair: Forfeit vruntime " Fernand Sieber
2025-09-16 16:00   ` Fernand Sieber
2025-09-18  6:43     ` Peter Zijlstra
2025-09-18 10:21       ` Peter Zijlstra
2025-09-18 15:05         ` [PATCH v3] " Fernand Sieber
2025-09-24  8:25           ` kernel test robot
2025-09-26  4:56           ` kernel test robot
2025-10-16  9:33           ` [tip: sched/core] " tip-bot2 for Fernand Sieber
2025-11-05  9:13           ` [PATCH v4] " Fernand Sieber
2025-09-17 19:22   ` [PATCH v2] " Fernand Sieber
2025-09-18  2:45   ` Xuewen Yan

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