[RFC PATCH v5 16/29] sched/rt: Allow zeroing the runtime of the root control group

Yuri Andriaccio
2026-04-30T21:39:08Z

Allow execution of FIFO/RR tasks in the root cgroup regardless of reserved
bandwidth.
Tasks in the root cgroup use the standard FIFO/RR scheduler.

Allow creation of cgroups with runtime or period zero.

Disallow execution of tasks in zero bandwidth cgroups.

---

In HCBS, the root control group follows the already existing rules for
rt-task scheduling. As such, it does not make use of the deadline servers
to account for runtime, or any other HCBS specific code and features.

While the runtime of SCHED_DEADLINE tasks depends on the global bandwidth
reserved for rt_tasks, the runtime of SCHED_FIFO/SCHED_RR tasks is limited
by the activation of fair-servers (as the RT_THROTTLING mechanism has been
removed in favour of them), thus their maximum bandwidth depends solely on
the fair-server settings (which are thightly related to the global
bandwidth reserved for rt-tasks) and the amount of SCHED_OTHER workload to
run (recall that if no SCHED_OTHER tasks are running, the FIFO/RR tasks
may fully utilize the CPU).

The values of runtime and period in the root cgroup's cpu controller do
not affect, by design of HCBS, the fair-server settings and similar
(consequently they do not affect the scheduling of FIFO/RR tasks in the
root cgroup), but they are just used to reserve a portion of the
SCHED_DEADLINE bandwidth to the scheduling of rt-cgroups. These values
only affect child cgroups, their deadline servers and their assigned
FIFO/RR tasks.

Signed-off-by: Yuri Andriaccio <yurand2000@gmail.com>
---
kernel/sched/rt.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index c994447f5b1c..5caddc5c2876 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2085,7 +2085,8 @@ static int tg_rt_schedulable(struct task_group *tg, void *data)
/*
* Ensure we don't starve existing RT tasks if runtime turns zero.
*/
- if (dl_bandwidth_enabled() && !runtime && tg_has_rt_tasks(tg))
+ if (dl_bandwidth_enabled() && tg != &root_task_group &&
+ !runtime && tg_has_rt_tasks(tg))
return -EBUSY;

if (WARN_ON(!rt_group_sched_enabled() && tg != &root_task_group))
@@ -2153,13 +2154,6 @@ static int tg_set_rt_bandwidth(struct task_group *tg,
static DEFINE_MUTEX(rt_constraints_mutex);
int i, err = 0;

- /*
- * Disallowing the root group RT runtime is BAD, it would disallow the
- * kernel creating (and or operating) RT threads.
- */
- if (tg == &root_task_group && rt_runtime == 0)
- return -EINVAL;
-
/*
* Bound quota to defend quota against overflow during bandwidth shift.
*/
@@ -2242,6 +2236,10 @@ static int sched_rt_global_constraints(void)

int sched_rt_can_attach(struct task_group *tg)
{
+ /* Allow executing in the root cgroup regardless of allowed bandwidth */
+ if (tg == &root_task_group)
+ return 1;
+
/* Don't accept real-time tasks when there is no way for them to run */
if (rt_group_sched_enabled() && tg->dl_bandwidth.dl_runtime == 0)
return 0;
--
2.53.0