mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Guanyou.Chen" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Qiaoting.Lin" <linqiaoting@xiaomi.com>,
	"Guanyou.Chen" <chenguanyou@xiaomi.com>,
	"Chunhui.Li" <chunhui.li@mediatek.com>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: sched/core] sched: restore timer_slack_ns when resetting RT policy on fork
Date: Thu, 04 Jun 2026 18:45:32 -0000	[thread overview]
Message-ID: <178059873259.710.9910245395140681179.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20260522131000.1664983-2-chenguanyou@xiaomi.com>

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     63c1a12bc0e09af7dee919c4fb4a300a719d5125
Gitweb:        https://git.kernel.org/tip/63c1a12bc0e09af7dee919c4fb4a300a719d5125
Author:        Guanyou.Chen <chenguanyou9338@gmail.com>
AuthorDate:    Fri, 22 May 2026 21:09:59 +08:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Tue, 02 Jun 2026 12:26:10 +02:00

sched: restore timer_slack_ns when resetting RT policy on fork

Commit ed4fb6d7ef68 ("hrtimer: Use and report correct timerslack values
for realtime tasks") sets timer_slack_ns to 0 for RT tasks in
__setscheduler_params(). However, when an RT task with SCHED_RESET_ON_FORK
creates child threads, the children inherit timer_slack_ns=0 from the
parent. sched_fork() resets the child's policy to SCHED_NORMAL but does
not restore timer_slack_ns, leaving the child permanently running with
zero slack.

Fix this by restoring timer_slack_ns from default_timer_slack_ns in
sched_fork() when resetting from RT/DL to NORMAL policy, matching the
existing behavior in __setscheduler_params().

Note: this fix alone requires a correct default_timer_slack_ns to be
effective. See the following patch for that fix.

Fixes: ed4fb6d7ef68 ("hrtimer: Use and report correct timerslack values for realtime tasks")
Reported-by: Qiaoting.Lin <linqiaoting@xiaomi.com>
Signed-off-by: Guanyou.Chen <chenguanyou@xiaomi.com>
Signed-off-by: Chunhui.Li <chunhui.li@mediatek.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260522131000.1664983-2-chenguanyou@xiaomi.com
---
 kernel/sched/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 5a317f6..2cfe893 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4826,6 +4826,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);
 

  reply	other threads:[~2026-06-04 18:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-21  2:52 [PATCH] " Guanyou.Chen
2026-05-21  3:18 ` Cunlong Li
2026-05-21  6:31   ` Guanyou Chen
2026-05-21  7:04 ` Peter Zijlstra
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-06-04 18:45       ` tip-bot2 for Guanyou.Chen [this message]
2026-05-22 13:10     ` [PATCH v3 2/2] fork: fix default_timer_slack_ns inheritance from RT parent Guanyou.Chen
2026-05-29 13:29     ` [PATCH v3 0/2] sched/fork: fix timer_slack_ns for children of RT tasks Guanyou.Chen
2026-06-03  3:20       ` Cunlong Li
2026-06-16 10:56     ` 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=178059873259.710.9910245395140681179.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=chenguanyou@xiaomi.com \
    --cc=chunhui.li@mediatek.com \
    --cc=linqiaoting@xiaomi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.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

all inboxes | Powered by JetHome®