* [PATCH] sched/deadline: Clamp negative runtime in sched_getattr
@ 2026-11-03 17:10 Avi Weiss
0 siblings, 0 replies; only message in thread
From: Avi Weiss @ 2026-11-03 17:10 UTC (permalink / raw)
To: mingo, peterz
Cc: juri.lelli, vincent.guittot, dietmar.eggemann, tommaso.cucinotta,
linux-kernel, linux-api, Avi Weiss
A SCHED_DEADLINE task can overrun its execution budget, leaving
dl_se->runtime negative until replenishment. Dynamic sched_getattr()
copies this signed value into the unsigned sched_attr.sched_runtime,
causing userspace to see a value near U64_MAX instead of zero
remaining budget.
Clamp negative runtime to zero when reporting the dynamic value.
Keep the signed deadline accounting unchanged.
Reproduced the overflow on an unpatched 7.4-rc1 kernel in a QEMU
guest. Verified that the patched kernel reports zero for negative
runtime, while positive runtime, static parameters, replenishment,
and non-deadline queries behave as expected.
A five-run VM benchmark of the unchanged static sched_getattr()
path showed no apparent regression (median 110.62 ns before,
102.10 ns after). Negligible improvement maybe just due to noise.
Fixes: 2e7af192697e ("sched/deadline: Add reporting of runtime left & abs deadline to sched_getattr() for DEADLINE tasks")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
kernel/sched/deadline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
index c0ebdcde5fe5..7b098da8076c 100644
--- a/kernel/sched/deadline.c
+++ b/kernel/sched/deadline.c
@@ -3870,7 +3870,7 @@ void __getparam_dl(struct task_struct *p, struct sched_attr *attr, unsigned int
if (task_current(rq, p))
update_curr_dl(rq);
- attr->sched_runtime = dl_se->runtime;
+ attr->sched_runtime = max_t(s64, dl_se->runtime, 0);
adj_deadline = dl_se->deadline - rq_clock(rq) + ktime_get_ns();
attr->sched_deadline = adj_deadline;
} else {
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-03 17:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 17:10 [PATCH] sched/deadline: Clamp negative runtime in sched_getattr Avi Weiss
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®