mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RESEND] In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.
@ 2026-02-11  2:12 Chen Jinghuang
  2026-02-12  3:39 ` Madadi Vineeth Reddy
  0 siblings, 1 reply; 8+ messages in thread
From: Chen Jinghuang @ 2026-02-11  2:12 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel

For example:

	# cat /proc/sys/kernel/sched_rt_runtime_us
	950000
	# echo 940000 > /proc/sys/kernel/sched_rt_runtime_us
	-bash: echo: write error: Invalid argument

This occurs because when the global RT quota is reduced while the root
cgroup’s ratio remains unchanged, the root cgroup’s proportion ends up
exceeding the global RT ratio. This is unreasonable: the root cgroup’s
ratio should be updated when the global RT ratio changes.

This patch ensures the root cgroup’s RT quota is adjusted whenever the
global RT quota is modified.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Signed-off-by: Chen Jinghuang <chenjinghuang2@huawei.com>
---
 kernel/sched/rt.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index f1867fe8e5c5..30770ba7be4e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2814,9 +2814,11 @@ long sched_group_rt_period(struct task_group *tg)
 static int sched_rt_global_constraints(void)
 {
 	int ret = 0;
+	u64 period = global_rt_period();
+	u64 runtime = global_rt_runtime();
 
 	mutex_lock(&rt_constraints_mutex);
-	ret = __rt_schedulable(NULL, 0, 0);
+	ret = __rt_schedulable(&root_task_group, period, runtime);
 	mutex_unlock(&rt_constraints_mutex);
 
 	return ret;
@@ -2856,6 +2858,14 @@ static int sched_rt_global_validate(void)
 
 static void sched_rt_do_global(void)
 {
+#ifdef CONFIG_RT_GROUP_SCHED
+	if (!rt_group_sched_enabled())
+		return;
+
+	WARN_ON_ONCE(tg_set_rt_bandwidth(&root_task_group,
+					global_rt_period(),
+					global_rt_runtime()));
+#endif
 }
 
 static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [RESEND] In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.
@ 2026-03-20  1:34 Chen Jinghuang
  2026-03-27  3:53 ` chenjinghuang
  0 siblings, 1 reply; 8+ messages in thread
From: Chen Jinghuang @ 2026-03-20  1:34 UTC (permalink / raw)
  To: mingo, peterz, juri.lelli, vincent.guittot, linux-kernel
  Cc: dietmar.eggemann, rostedt, bsegall, mgorman, vschneid

For example:

	# cat /proc/sys/kernel/sched_rt_runtime_us
	950000
	# echo 940000 > /proc/sys/kernel/sched_rt_runtime_us
	-bash: echo: write error: Invalid argument

This occurs because when the global RT quota is reduced while the root
cgroup’s ratio remains unchanged, the root cgroup’s proportion ends up
exceeding the global RT ratio. This is unreasonable: the root cgroup’s
ratio should be updated when the global RT ratio changes.

This patch ensures the root cgroup’s RT quota is adjusted whenever the
global RT quota is modified.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Tested-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Reviewed-by: Chen Jinghuang <chenjinghuang2@huawei.com>
---
 kernel/sched/rt.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index f1867fe8e5c5..30770ba7be4e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2814,9 +2814,11 @@ long sched_group_rt_period(struct task_group *tg)
 static int sched_rt_global_constraints(void)
 {
 	int ret = 0;
+	u64 period = global_rt_period();
+	u64 runtime = global_rt_runtime();
 
 	mutex_lock(&rt_constraints_mutex);
-	ret = __rt_schedulable(NULL, 0, 0);
+	ret = __rt_schedulable(&root_task_group, period, runtime);
 	mutex_unlock(&rt_constraints_mutex);
 
 	return ret;
@@ -2856,6 +2858,14 @@ static int sched_rt_global_validate(void)
 
 static void sched_rt_do_global(void)
 {
+#ifdef CONFIG_RT_GROUP_SCHED
+	if (!rt_group_sched_enabled())
+		return;
+
+	WARN_ON_ONCE(tg_set_rt_bandwidth(&root_task_group,
+					global_rt_period(),
+					global_rt_runtime()));
+#endif
 }
 
 static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [RESEND] In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.
@ 2026-02-26  3:38 Chen Jinghuang
  2026-02-27  8:18 ` Chen Ridong
  0 siblings, 1 reply; 8+ messages in thread
From: Chen Jinghuang @ 2026-02-26  3:38 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel

For example:

	# cat /proc/sys/kernel/sched_rt_runtime_us
	950000
	# echo 940000 > /proc/sys/kernel/sched_rt_runtime_us
	-bash: echo: write error: Invalid argument

This occurs because when the global RT quota is reduced while the root
cgroup’s ratio remains unchanged, the root cgroup’s proportion ends up
exceeding the global RT ratio. This is unreasonable: the root cgroup’s
ratio should be updated when the global RT ratio changes.

This patch ensures the root cgroup’s RT quota is adjusted whenever the
global RT quota is modified.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Signed-off-by: Chen Jinghuang <chenjinghuang2@huawei.com>
---
 kernel/sched/rt.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index f1867fe8e5c5..30770ba7be4e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2814,9 +2814,11 @@ long sched_group_rt_period(struct task_group *tg)
 static int sched_rt_global_constraints(void)
 {
 	int ret = 0;
+	u64 period = global_rt_period();
+	u64 runtime = global_rt_runtime();
 
 	mutex_lock(&rt_constraints_mutex);
-	ret = __rt_schedulable(NULL, 0, 0);
+	ret = __rt_schedulable(&root_task_group, period, runtime);
 	mutex_unlock(&rt_constraints_mutex);
 
 	return ret;
@@ -2856,6 +2858,14 @@ static int sched_rt_global_validate(void)
 
 static void sched_rt_do_global(void)
 {
+#ifdef CONFIG_RT_GROUP_SCHED
+	if (!rt_group_sched_enabled())
+		return;
+
+	WARN_ON_ONCE(tg_set_rt_bandwidth(&root_task_group,
+					global_rt_period(),
+					global_rt_runtime()));
+#endif
 }
 
 static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [RESEND] In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.
@ 2026-02-08 10:29 Chen Jinghuang
  0 siblings, 0 replies; 8+ messages in thread
From: Chen Jinghuang @ 2026-02-08 10:29 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra, Juri Lelli, Vincent Guittot
  Cc: Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman,
	Valentin Schneider, linux-kernel

For example:

	# cat /proc/sys/kernel/sched_rt_runtime_us
	950000
	# echo 940000 > /proc/sys/kernel/sched_rt_runtime_us
	-bash: echo: write error: Invalid argument

This occurs because when the global RT quota is reduced while the root
cgroup’s ratio remains unchanged, the root cgroup’s proportion ends up
exceeding the global RT ratio. This is unreasonable: the root cgroup’s
ratio should be updated when the global RT ratio changes.

This patch ensures the root cgroup’s RT quota is adjusted whenever the
global RT quota is modified.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
Signed-off-by: Chen Jinghuang <chenjinghuang2@huawei.com>
---
 kernel/sched/rt.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index f1867fe8e5c5..30770ba7be4e 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2814,9 +2814,11 @@ long sched_group_rt_period(struct task_group *tg)
 static int sched_rt_global_constraints(void)
 {
 	int ret = 0;
+	u64 period = global_rt_period();
+	u64 runtime = global_rt_runtime();
 
 	mutex_lock(&rt_constraints_mutex);
-	ret = __rt_schedulable(NULL, 0, 0);
+	ret = __rt_schedulable(&root_task_group, period, runtime);
 	mutex_unlock(&rt_constraints_mutex);
 
 	return ret;
@@ -2856,6 +2858,14 @@ static int sched_rt_global_validate(void)
 
 static void sched_rt_do_global(void)
 {
+#ifdef CONFIG_RT_GROUP_SCHED
+	if (!rt_group_sched_enabled())
+		return;
+
+	WARN_ON_ONCE(tg_set_rt_bandwidth(&root_task_group,
+					global_rt_period(),
+					global_rt_runtime()));
+#endif
 }
 
 static int sched_rt_handler(const struct ctl_table *table, int write, void *buffer,
-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-04-20  4:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-11  2:12 [RESEND] In cgroup v2, setting a smaller value for sched_rt_runtime_us fails Chen Jinghuang
2026-02-12  3:39 ` Madadi Vineeth Reddy
  -- strict thread matches above, loose matches on Subject: below --
2026-03-20  1:34 Chen Jinghuang
2026-03-27  3:53 ` chenjinghuang
2026-04-20  4:03   ` chenjinghuang
2026-02-26  3:38 Chen Jinghuang
2026-02-27  8:18 ` Chen Ridong
2026-02-08 10:29 Chen Jinghuang

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®