[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251007122904.31611-1-gmonaco@redhat.com>
Date: Tue, 7 Oct 2025 14:29:04 +0200
From: Gabriele Monaco <gmonaco@...hat.com>
To: linux-kernel@...r.kernel.org,
Juri Lelli <juri.lelli@...hat.com>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>
Cc: Gabriele Monaco <gmonaco@...hat.com>,
Clark Williams <williams@...hat.com>
Subject: [RFC PATCH] sched/deadline: Avoid dl_server boosting with expired deadline
Recent changes to the deadline server leave it running when the system
is idle. If the system is idle for longer than the dl_server period and
the first scheduling occurs after a fair task wakes up, the algorithm
picks the server as the earliest deadline (in the past) and that boosts
the fair task that just woke up while:
* the deadline is in the past
* the server consumed all its runtime (in background)
* there is no starvation (idle for about a period)
Prevent the server from boosting a task when the deadline is in the
past. Instead, replenish a new period and start the server as deferred.
Fixes: 4ae8d9aa9f9d ("sched/deadline: Fix dl_server getting stuck")
To: Juri Lelli <juri.lelli@...hat.com>
Cc: Clark Williams <williams@...hat.com>
Signed-off-by: Gabriele Monaco <gmonaco@...hat.com>
---
This behaviour was observed using the RV monitors in [1] and the patch
was validated on an adapted version of the models. The models are not
exhaustively validating the dl_server behaviour.
[1] - https://lore.kernel.org/lkml/20250919140954.104920-21-gmonaco@redhat.com
kernel/sched/deadline.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index 72c1f72463c7..b3e3d506a18d 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2371,6 +2371,17 @@ static struct task_struct *__pick_task_dl(struct rq *rq)
dl_server_stop(dl_se);
goto again;
}
+ /*
+ * If the CPU was idle for long enough time and wakes up
+ * because of a fair task, the dl_server may run after its
+ * period elapsed. Replenish a new period as deferred, since we
+ * are clearly not handling starvation here.
+ */
+ if (dl_time_before(dl_se->deadline, rq_clock(rq))) {
+ dl_se->dl_defer_running = 0;
+ replenish_dl_new_period(dl_se, rq);
+ goto again;
+ }
rq->dl_server = dl_se;
} else {
p = dl_task_of(dl_se);
base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a
--
2.51.0
Powered by blists - more mailing lists