Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Guanyou.Chen" <chenguanyou9338@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>,
	Juri Lelli <juri.lelli@redhat.com>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Thomas Gleixner <tglx@kernel.org>,
	Felix Moessbauer <felix.moessbauer@siemens.com>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Steven Rostedt <rostedt@goodmis.org>, Kees Cook <kees@kernel.org>,
	chenguanyou@xiaomi.com, linqiaoting@xiaomi.com,
	chunhui.li@mediatek.com, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH] sched: restore timer_slack_ns when resetting RT policy on fork
Date: Thu, 21 May 2026 09:04:40 +0200	[thread overview]
Message-ID: <20260521070440.GD3126523@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20260521025250.1469390-1-chenguanyou@xiaomi.com>

On Thu, May 21, 2026 at 10:52:50AM +0800, Guanyou.Chen wrote:
> diff --git a/init/init_task.c b/init/init_task.c
> index 5c838757fc10..57ff8dae9bfb 100644
> --- a/init/init_task.c
> +++ b/init/init_task.c
> @@ -170,6 +170,7 @@ struct task_struct init_task __aligned(L1_CACHE_BYTES) = {
>  	INIT_CPU_TIMERS(init_task)
>  	.pi_lock	= __RAW_SPIN_LOCK_UNLOCKED(init_task.pi_lock),
>  	.timer_slack_ns = 50000, /* 50 usec default slack */
> +	.default_timer_slack_ns = 50000, /* 50 usec default slack */
>  	.thread_pid	= &init_struct_pid,
>  	.thread_node	= LIST_HEAD_INIT(init_signals.thread_head),
>  #ifdef CONFIG_AUDIT
> diff --git a/kernel/fork.c b/kernel/fork.c
> index 65113a304518..8358df80e11d 100644
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -2133,8 +2133,6 @@ __latent_entropy struct task_struct *copy_process(
>  	retval = -EAGAIN;
>  #endif
>  
> -	p->default_timer_slack_ns = current->timer_slack_ns;
> -
>  #ifdef CONFIG_PSI
>  	p->psi_flags = 0;
>  #endif

Cunlong makes a good point in that this changes behaviour. That said I
do find the current behaviour 'odd'.

*IF* we want to change this (and changing behaviour is always dodgy),
then it should be a separate patch with a separate justification.

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index b7f77c165a6e..b1a241810ce0 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -4649,6 +4649,7 @@ int sched_fork(u64 clone_flags, struct task_struct *p)
>  			p->policy = SCHED_NORMAL;
>  			p->static_prio = NICE_TO_PRIO(0);
>  			p->rt_priority = 0;
> +			p->timer_slack_ns = p->default_timer_slack_ns;
>  		} else if (PRIO_TO_NICE(p->static_prio) < 0)
>  			p->static_prio = NICE_TO_PRIO(0);

Yes, this matches __setscheduler_param(). And yes, this wants to be
done.


Anyway, while looking at all this I found that the manpages specify
RESET_ON_FORK to apply to CAP_SYS properties; which is a tad awkward,
esp if we end up allowing unpriv access to DL (or even FIFO/RR when
isolated in a bandwidth group).

Additionally, it doesn't look like PR_SET_TIMERSLACK is CAP_SYS guarded
itself, so this is all a bit of a mess.





  parent reply	other threads:[~2026-05-21  7:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21  2:52 [PATCH] sched: restore timer_slack_ns when resetting RT policy on fork Guanyou.Chen
2026-05-21  3:18 ` Cunlong Li
2026-05-21  6:23   ` Guanyou Chen
2026-05-21  6:31   ` Guanyou Chen
2026-05-21  7:04 ` Peter Zijlstra [this message]
2026-05-21  7:35   ` [PATCH v2 0/2] sched: fix timer_slack_ns for children of RT tasks Guanyou.Chen
2026-05-21  7:35     ` [PATCH 1/2] sched: restore timer_slack_ns when resetting RT policy on fork Guanyou.Chen
2026-05-21  7:35     ` [PATCH 2/2] fork: fix default_timer_slack_ns inheritance from RT parent Guanyou.Chen
2026-05-22 13:09   ` [PATCH v3 0/2] sched/fork: fix timer_slack_ns for children of RT tasks Guanyou.Chen
2026-05-22 13:09     ` [PATCH v3 1/2] sched: restore timer_slack_ns when resetting RT policy on fork Guanyou.Chen
2026-05-22 13:10     ` [PATCH v3 2/2] fork: fix default_timer_slack_ns inheritance from RT parent Guanyou.Chen

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=20260521070440.GD3126523@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=chenguanyou9338@gmail.com \
    --cc=chenguanyou@xiaomi.com \
    --cc=chunhui.li@mediatek.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=felix.moessbauer@siemens.com \
    --cc=juri.lelli@redhat.com \
    --cc=kees@kernel.org \
    --cc=linqiaoting@xiaomi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --cc=vincent.guittot@linaro.org \
    /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