[PATCH v4 09/26] sched/deadline: Reset the deadline and the runtime with the parameters

From: Mathieu Desnoyers

Date: Fri Nov 06 2026 - 20:49:31 EST


A task that leaves SCHED_DEADLINE keeps its parameters until its 0-lag
time, so that leaving and coming back gains nothing. __dl_clear_params()
then resets them, in inactive_task_timer() or in task_non_contending(),
but leaves the deadline and the runtime of the period the task was in.

A task that comes back after its 0-lag time, and before that deadline,
is enqueued on them: enqueue_dl_entity() starts a period anew for a
task whose deadline passed, setup_new_dl_entity(), and for no other. The
task spends the runtime of the reservation it gave back before the new
one begins, and a constrained task whose deadline passed before the end
of its period is throttled on them instead, dl_check_constrained_dl()
arming the replenishment timer of the old period. The previous patch
widens the window to a period for a task that was throttled, moving its
deadline on where its timer fires outside the class.

A task boosted into the class by priority inheritance, with no
parameters of its own, runs on the donor's deadline and runtime, and
keeps them after its deboost: switched_from_dl() resets nothing for it,
and a change into the class before that deadline is enqueued on them as
well.

Reset them with the parameters, and on the deboost of a task that has
none: the next enqueue then starts a period from the parameters the
task has. The deadline_bw_test selftest added later in this series has
the case, deboost_resets_period.

Found by the Sashiko AI review of the second posting of this series, the
deboost by that of the third.

Fixes: 209a0cbda7a0 ("sched/deadline: Improve the tracking of active utilization")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
---
kernel/sched/deadline.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index b8b0076870a6..f389620e6fc9 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -3580,6 +3580,16 @@ static void switched_from_dl(struct rq *rq, struct task_struct *p)
if (task_on_rq_queued(p) && p->dl.dl_runtime)
task_non_contending(&p->dl, false);

+ /*
+ * Deboosted from priority inheritance with no parameters of its own:
+ * the deadline and the runtime are the donor's. A change into the
+ * class then starts a period from the parameters it is given.
+ */
+ if (!p->dl.dl_runtime) {
+ p->dl.deadline = 0;
+ p->dl.runtime = 0;
+ }
+
/*
* In case a task is setscheduled out from SCHED_DEADLINE we need to
* keep track of that on its cpuset (for correct bandwidth tracking).
@@ -4006,6 +4016,9 @@ static void __dl_clear_params(struct sched_dl_entity *dl_se)
dl_se->dl_bw = 0;
dl_se->dl_density = 0;

+ dl_se->deadline = 0;
+ dl_se->runtime = 0;
+
dl_se->dl_throttled = 0;
dl_se->dl_yielded = 0;
dl_se->dl_non_contending = 0;
--
2.47.3