[PATCH v2] In cgroup v2, setting a smaller value for sched_rt_runtime_us fails.

From: Chen Jinghuang

Date: Thu Jun 25 2026 - 07:26:59 EST


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

With CONFIG_RT_GROUP_SCHED enabled, reducing the global RT quota
causes the unchanged root cgroup quota to exceed the new global limit.
The root cgroup quota should be updated accordingly when the global
quota changes.

Adjust the root cgroup's RT quota whenever the global RT quota is
modified.

Signed-off-by: Chen Jinghuang <chenjinghuang2@xxxxxxxxxx>
Reviewed-by: Ridong Chen <ridong.chen@xxxxxxxxx>
Tested-by: Madadi Vineeth Reddy <vineethr@xxxxxxxxxxxxx>
---
Change since v1: https://lore.kernel.org/all/20260320013419.2493925-1-chenjinghuang2@xxxxxxxxxx/
- Rebase the patch onto mainline.
---
kernel/sched/rt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index e474c31d8fe6..b1b082e365af 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2858,9 +2858,12 @@ static int sched_rt_global_validate(void)
#ifdef CONFIG_RT_GROUP_SCHED
if (!rt_group_sched_enabled())
return 0;
+
+ u64 period = global_rt_period();
+ u64 runtime = global_rt_runtime();

scoped_guard(mutex, &rt_constraints_mutex)
- return __rt_schedulable(NULL, 0, 0);
+ return __rt_schedulable(&root_task_group, period, runtime);
#endif
return 0;
}
--
2.34.1