[Question] sched_rt_runtime_us adjustment differs between cgroup v1 and v2 (EINVAL issue)

From: chenjinghuang

Date: Mon Feb 02 2026 - 06:44:49 EST


I hope this email finds you well. I'm reaching out to clarify a behavioral difference between cgroup v1 and v2 when adjusting the global sched_rt_runtime_us sysctl parameter, which I've encountered during testing. Below is a detailed description of the issue and my core question:

1. Background & Problem Phenomenon
The default value of /proc/sys/kernel/sched_rt_runtime_us is 950000 us (0.95s). When I attempt to lower this value (e.g., `echo 940000 > /proc/sys/kernel/sched_rt_runtime_us`) in a cgroup v2-only environment, the operation fails with "Invalid argument" (EINVAL).
By tracing the kernel code, I found the failure originates from the tg_rt_schedulable() function, where the following check enforces that the total RT runtime of all task groups (tg->rt_bandwidth.rt_runtime) cannot exceed the global sched_rt_runtime_us:
/* * Nobody can have more than the global setting allows. */
if (total > to_ratio(global_rt_period(), global_rt_runtime()))
return -EINVAL;

2. Key Difference Between cgroup v1 and v2
cgroup v1: I can work around this restriction by first modifying /sys/fs/cgroup/cpu/cpu.rt_runtime_us (the user-space interface for tg->rt_bandwidth.rt_runtime), lowering the root cgroup's RT runtime (e.g., to 940000 us). After this adjustment, setting
sched_rt_runtime_us to 940000us succeeds without EINVAL.
cgroup v2: The cpu.rt_runtime_us interface is no longer available. As a result, there is no way to lower the root cgroup's tg->rt_bandwidth.rt_runtime first, which blocks any attempt to set sched_rt_runtime_us to a value below 950000 us.

3. Core question
Can you explain the design considerations behind this behavioral difference between cgroup v1 and v2 ? Specially:
1. Why was the direct adjustment of tg->rt_bandwidth.rt_runtime (via cpu.rt_runtime_us) removed in cgroup v2 ?
2. Is there an correct way to lower the global sched_rt_runtime_us in cgroup v2?

I appreciate any insights or guidance you can provide. Thank you for your time and help!