* [PATCH] sched: Preserve timer slack default across RT reset-on-fork
@ 2026-06-22 2:50 zhidao su (Xiaomi)
0 siblings, 0 replies; only message in thread
From: zhidao su (Xiaomi) @ 2026-06-22 2:50 UTC (permalink / raw)
To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
Valentin Schneider, K Prateek Nayak, Andrew Morton,
David Hildenbrand, Lorenzo Stoakes, Liam R . Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Kees Cook, Felix Moessbauer, Thomas Gleixner, linux-kernel,
linux-mm, zhidao su (Xiaomi)
RT and deadline policies force timer_slack_ns to zero while a task runs
under the realtime policy. The original slack value is kept in
default_timer_slack_ns so it can be restored when the task returns to a
normal policy.
copy_process() initializes the child's default_timer_slack_ns from
current->timer_slack_ns. For an RT/DL parent this copies the temporary
zero value into the child's default. If the parent also uses
SCHED_RESET_ON_FORK, sched_fork() resets the child to SCHED_NORMAL and
restores timer_slack_ns from that already-poisoned default, leaving the
child with zero slack.
Preserve current->default_timer_slack_ns when current->timer_slack_ns is
zero so reset-on-fork children can restore a real default slack value.
Fixes: ed4fb6d7ef68 ("hrtimer: Use and report correct timerslack values for realtime tasks")
Signed-off-by: zhidao su (Xiaomi) <soolaugust@gmail.com>
---
kernel/fork.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index addc555a1077..39db7502379b 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -2196,7 +2196,14 @@ __latent_entropy struct task_struct *copy_process(
retval = -EAGAIN;
#endif
- p->default_timer_slack_ns = current->timer_slack_ns;
+ /*
+ * RT/DL tasks run with timer_slack_ns forced to zero, but their
+ * default_timer_slack_ns still carries the value to restore when
+ * returning to a normal policy. Preserve that default across fork so
+ * SCHED_RESET_ON_FORK children can restore a real slack value.
+ */
+ p->default_timer_slack_ns = current->timer_slack_ns ?:
+ current->default_timer_slack_ns;
#ifdef CONFIG_PSI
p->psi_flags = 0;
base-commit: e771677c937da5808f7b6c1f0e4a97ec1a84f8a8
--
2.43.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-22 2:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-22 2:50 [PATCH] sched: Preserve timer slack default across RT reset-on-fork zhidao su (Xiaomi)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox