mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH sched/urgent] sched/deadline: Fix stale rq->dl_server after a server pick returns RETRY_TASK
@ 2026-10-30 22:18 Tejun Heo
  2026-10-30 23:56 ` Tejun Heo
  2026-10-31  1:19 ` Tejun Heo
  0 siblings, 2 replies; 3+ messages in thread
From: Tejun Heo @ 2026-10-30 22:18 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Juri Lelli, Vincent Guittot
  Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, K Prateek Nayak, linux-kernel, Tejun Heo

__pick_task_dl() records the server in rq->dl_server whenever the server's
pick returns non-NULL, RETRY_TASK included. __pick_next_task() clears
rq->dl_server at its top, but a RETRY_TASK restarts the pick below that
clear. put_prev_set_next_task() then hands the stale server to whatever the
restarted pick takes.

Since b3a2dfa8b42e ("sched/fair: Add newidle balance to pick_task_fair()"),
fair_server_pick_task() returns RETRY_TASK when the newidle balance released
the rq lock and a higher class task was enqueued meanwhile.

That task, an RT task for example, then carries the fair server in
p->dl_server until it is next put. The RV deadline monitors see the fair
server switch in with it, and core scheduling, if enabled meanwhile, treats
the task as deadline priority.

Don't record the server when its pick returns RETRY_TASK. The restarted pick
records whichever server it goes through, if any.

Verified with a synthetic reproducer.

Fixes: b3a2dfa8b42e ("sched/fair: Add newidle balance to pick_task_fair()")
Signed-off-by: Tejun Heo <tj@kernel.org>
---
 kernel/sched/deadline.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index c0ebdcde5fe5..cc9c7cb7dc42 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2836,6 +2836,13 @@ static struct task_struct *__pick_task_dl(struct rq *rq, struct rq_flags *rf)
 			dl_server_stop(dl_se);
 			goto again;
 		}
+		/*
+		 * RETRY_TASK restarts the pick. Don't record @dl_se, or
+		 * put_prev_set_next_task() hands it to whatever the restarted
+		 * pick takes.
+		 */
+		if (p == RETRY_TASK)
+			return p;
 		rq->dl_server = dl_se;
 	} else {
 		p = dl_task_of(dl_se);
-- 
2.56.0


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

end of thread, other threads:[~2026-10-31  1:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 22:18 [PATCH sched/urgent] sched/deadline: Fix stale rq->dl_server after a server pick returns RETRY_TASK Tejun Heo
2026-10-30 23:56 ` Tejun Heo
2026-10-31  1:19 ` Tejun Heo

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

all inboxes | Powered by JetHome®