[PATCH] sched/deadline: Restore dequeue schedstats on the task dequeue path

From: Zhan Xusheng

Date: Wed Oct 14 2026 - 10:49:27 EST


update_stats_dequeue_dl() writes p->stats.sleep_start and
p->stats.block_start, and nothing else in deadline.c does. Its only
caller is update_curr_dl_se(), on the throttle path, which passes
flags = 0, so the DEQUEUE_SLEEP branch that performs those writes never
runs.

Both fields therefore stay zero for SCHED_DEADLINE tasks, and
__update_stats_enqueue_sleeper() skips its work under
`if (sleep_start)` / `if (block_start)`. A deadline task reports zero
sleep_max, sum_sleep_runtime, block_max, sum_block_runtime, iowait_sum
and iowait_count in /proc/PID/sched, emits no sched_stat_sleep,
sched_stat_blocked or sched_stat_iowait, and contributes nothing to
latencytop.

Commit b5eb4a5f6521 ("sched/dl: Support schedstats for deadline sched
class") called it from __dequeue_task_dl(), on the task dequeue path,
with flags passed through, mirroring update_stats_dequeue_fair(). That
was the only call. Commit 63ba8422f876 ("sched/deadline: Introduce
deadline servers") replaced __dequeue_task_dl() with dequeue_dl_entity()
and added the throttle-path call instead of carrying the old one over.

Call it from dequeue_task_dl(), after the DEQUEUE_MIGRATING fixup so the
flags are complete. dequeue_dl_entity() would be the wrong place:
dl_server_stop() reaches it with a server entity, for which dl_task_of()
does not yield a task.

Guard on on_dl_rq(), as set_next_task_dl() and put_prev_task_dl() do.
Without it a throttled task would be accounted twice, once by the
throttle path that dequeued its entity and once here, and the second
update_stats_wait_end_dl() would run against a wait_start the first one
had already cleared.

Restoring the call also makes the migration case behave as intended.
deactivate_task() sets TASK_ON_RQ_MIGRATING before dequeue_task(), so
__update_stats_wait_end() now takes its task_on_rq_migrating() branch and
carries the accumulated wait time into wait_start instead of finalising
it, which is what commit c0e1832ba6da ("sched: Fix incorrect schedstats
for rt and dl thread") aimed for but could not reach on deadline.

Fixes: 63ba8422f876 ("sched/deadline: Introduce deadline servers")
Signed-off-by: Zhan Xusheng <zhanxusheng@xxxxxxxxxx>
---
kernel/sched/deadline.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index c0ebdcde5fe5d..ba09f5a3c256a 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -2556,6 +2556,8 @@ static bool dequeue_task_dl(struct rq *rq, struct task_struct *p, int flags)
if (task_on_rq_migrating(p))
flags |= DEQUEUE_MIGRATING;

+ if (on_dl_rq(&p->dl))
+ update_stats_dequeue_dl(&rq->dl, &p->dl, flags);
dequeue_dl_entity(&p->dl, flags);
if (!p->dl.dl_throttled && !dl_server(&p->dl))
dequeue_pushable_dl_task(rq, p);

base-commit: 4a3b51aab6e25244d97936aa65e6d5425adf98e1
--
2.43.0