From: K Prateek Nayak <kprateek.nayak@amd.com>
To: <xiaofeng5@xiaomi.com>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
David Hildenbrand <david@kernel.org>,
Lorenzo Stoakes <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
Vlastimil Babka <vbabka@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
Michal Hocko <mhocko@suse.com>, Kees Cook <kees@kernel.org>,
Felix Moessbauer <felix.moessbauer@siemens.com>,
"Thomas Gleixner" <tglx@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH] sched/fork: Fix timer_slack_ns inheritance for RT tasks
Date: Wed, 20 May 2026 20:27:49 +0530 [thread overview]
Message-ID: <5bf30954-7c88-4cbc-a529-9d5465e22ee4@amd.com> (raw)
In-Reply-To: <20260520-sched-fork-fix-timer-slack-v1-1-d4fc937245b2@xiaomi.com>
Hello Xiao,
On 5/20/2026 6:37 PM, Xiao Feng via B4 Relay wrote:
> Both problems prevent timer coalescing for these CFS tasks, causing
> unnecessary wakeups and increased power consumption. Writing 0 to
> /proc/pid/timerslack_ns also cannot restore a proper default.
>
> Fix both issues:
>
> 1. In copy_process(), inherit default_timer_slack_ns from the parent's
> default_timer_slack_ns (which is preserved across RT transitions)
> instead of timer_slack_ns (which is 0 for RT tasks).
man page for fork() [1] reads:
The default timer slack value is set to the parent's current
timer slack value. See the description of PR_SET_TIMERSLACK in
prctl(2).
And that description in man page for PR_SET_TIMERSLACK [2] reads:
When a new thread is created, the two timer slack values are made
the same as the "current" value of the creating thread.
The two timer slack value that the man page refers to above is the
"default" and the "current" value as is describes in the opening
statement.
From a documentation standpoint, it is doing the right thing. A
RT thread returns 0 for PR_GET_TIMERSLACK and the same is set as
"default" and "current" for its children.
[1] https://man7.org/linux/man-pages/man2/fork.2.html
[2] https://man7.org/linux/man-pages/man2/pr_set_timerslack.2const.html
>
> 2. In sched_fork(), when sched_reset_on_fork demotes RT/DL to CFS,
> explicitly restore timer_slack_ns from the parent's
> default_timer_slack_ns, falling back to 50us if it is also 0.
As for SCHED_FLAG_RESET_ON_FORK, man page for sched() [3] reads:
More precisely, if the reset-on-fork flag is set, the following
rules apply for subsequently created children:
- If the calling thread has a scheduling policy of SCHED_FIFO or
SCHED_RR, the policy is reset to SCHED_OTHER in child
processes.
- If the calling process has a negative nice value, the nice
value is reset to zero in child processes.
After the reset-on-fork flag has been enabled, it can be reset
only if the thread has the CAP_SYS_NICE capability. This flag is
disabled in child processes created by fork(2).
Nowhere it says anything other than the scheduling policy is affected by
this flag. How is timer_slack any special?
[3] https://man7.org/linux/man-pages/man7/sched.7.html
>
> Fixes: ed4fb6d7ef68 ("hrtimer: Use and report correct timerslack values for realtime tasks")
Based on my reading, this is not fixing anything but instead introducing
a behavior change contrary to what has been currently documented.
If it is acceptable, at the very least, the man pages need to be updated
stating this new behavior and the kernel version that introduces it.
I'll let others comment since they know these bits better than me.
--
Thanks and Regards,
Prateek
next prev parent reply other threads:[~2026-05-20 14:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 13:07 Xiao Feng via B4 Relay
2026-05-20 14:57 ` K Prateek Nayak [this message]
2026-05-28 4:50 ` kernel test robot
2026-05-28 5:24 ` K Prateek Nayak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5bf30954-7c88-4cbc-a529-9d5465e22ee4@amd.com \
--to=kprateek.nayak@amd.com \
--cc=akpm@linux-foundation.org \
--cc=bsegall@google.com \
--cc=david@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=felix.moessbauer@siemens.com \
--cc=juri.lelli@redhat.com \
--cc=kees@kernel.org \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=tglx@kernel.org \
--cc=vbabka@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=xiaofeng5@xiaomi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®