[PATCH v10 36/40] sched/deadline: Reschedule a running task throttled at its enqueue
From: Mathieu Desnoyers
Date: Fri Nov 20 2026 - 15:46:14 EST
A task with a constrained deadline (dl_deadline < dl_period) can wake up
after its deadline but before its next period.
Commit df8eac8cafce ("sched/deadline: Throttle a constrained deadline
task activated after the deadline") throttles it then until that period.
A refill would let it run for dl_runtime every dl_deadline, more than
its reservation.
enqueue_dl_entity() makes this check at every enqueue, not only at a
wakeup. These changes to a running task also dequeue and enqueue it:
- sched_setattr() and sched_setaffinity();
- a cgroup move;
- a deboost in rt_mutex_setprio().
A task can run past its deadline with runtime left, for example after
tasks with earlier deadlines delayed it. The check then throttles it and
leaves it off the dl_rq. But nothing reschedules: prio_changed_dl() sees
the same deadline and returns.
The task keeps the CPU. update_curr_dl() skips a task that is off the
dl_rq, so the tick neither charges it nor preempts it. It runs until it
blocks, until a task with an earlier deadline wakes up, or until its
next period. That is up to dl_period - dl_deadline of CPU time outside
its reservation. The Sashiko AI review of this series found this. The
constrained_gap_change_running case, added to deadline_bw_test later
in this series, tests this. It fails without this patch.
Fix this by rescheduling when the check throttles the current task, as
a throttle in update_curr_dl_se() does.
Fixes: df8eac8cafce ("sched/deadline: Throttle a constrained deadline task activated after the deadline")
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx
---
kernel/sched/deadline.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index fe48137509ad..b9c206a59c16 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -1996,6 +1996,13 @@ static inline void dl_check_constrained_dl(struct sched_dl_entity *dl_se)
dl_se->dl_throttled = 1;
if (dl_se->runtime > 0)
dl_se->runtime = 0;
+ /*
+ * A running task is now off the dl_rq: the tick no longer
+ * charges it or preempts it. Reschedule, as a throttle in
+ * update_curr_dl_se() does.
+ */
+ if (!dl_server(dl_se) && task_current_donor(rq, dl_task_of(dl_se)))
+ resched_curr(rq);
}
}
--
2.47.3