Re: [PATCH v3 0/2] sched/fork: fix timer_slack_ns for children of RT tasks
From: Guanyou.Chen
Date: Tue Jun 16 2026 - 06:58:16 EST
Hi Peter,
tip commit 63c1a12bc0e0 ("sched: restore timer_slack_ns when resetting RT
policy on fork") restores timer_slack_ns from default_timer_slack_ns
when sched_fork() resets an RT/DL child back to SCHED_NORMAL. However,
without fixing the inheritance of default_timer_slack_ns, the restore
has no effect in the common case.
When an RT task with SCHED_RESET_ON_FORK creates child threads:
1. dup_task_struct() copies the parent's timer_slack_ns=0 and
default_timer_slack_ns=X to the child.
2. copy_process() then overwrites the child's default_timer_slack_ns
with current->timer_slack_ns, which is 0 for RT tasks (forced by
ed4fb6d7ef68).
3. sched_fork() resets the child to SCHED_NORMAL and restores
timer_slack_ns from default_timer_slack_ns -- but both are now 0.
The child ends up with timer_slack_ns=0 and default_timer_slack_ns=0,
with no way to restore a meaningful value via prctl(PR_SET_TIMERSLACK, 0)
or sched_setscheduler() back to NORMAL.
The patch v3 2/2 of this fix is at:
https://lore.kernel.org/lkml/20260522131000.1664983-3-chenguanyou@xxxxxxxxxx/
Could you review it? Without this fix the merged commit above is
effectively a no-op for the RT/RESET_ON_FORK case.
Thanks
Guanyou