[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20251127020125.657611-1-fangqiurong@kylinos.cn>
Date: Thu, 27 Nov 2025 10:01:25 +0800
From: fangqiurong <fangqiurong@...inos.cn>
To: mingo@...hat.com
Cc: peterz@...radead.org,
linux-kernel@...r.kernel.org,
fangqiurong <fangqiurong@...inos.cn>
Subject: [PATCH] sched: Fix RT task setup failures by disabling rt_bandwidth for cgroup v2
When CONFIG_RT_GROUP_SCHED is enabled, RT tasks cannot be created in non-root
cgroups under cgroup v2 because rt_runtime defaults to 0, causing
sched_setscheduler() to fail with -EPERM.
The cgroup v2 design makes per-cgroup RT bandwidth control impractical,
as non-root groups have no meaningful RT runtime allocation. In this
configuration, rt_bandwidth only serves as a starvation prevention mechanism
for CFS tasks, which is no longer necessary in modern schedulers.
This fix disables rt_bandwidth checks when using cgroup v2 with
CONFIG_RT_GROUP_SCHED, allowing RT tasks to be created normally while relying
on the scheduler's inherent fairness mechanisms instead of artificial bandwidth
limitations.
Signed-off-by: fangqiurong <fangqiurong@...inos.cn>
---
kernel/sched/sched.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index adfb6e340..f7290b80d 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -814,6 +814,12 @@ struct scx_rq {
static inline int rt_bandwidth_enabled(void)
{
+#ifdef CONFIG_RT_GROUP_SCHED
+ /* Disable rt_bandwidth for cgroup v2 */
+ if (root_task_group.css.cgroup &&
+ root_task_group.css.cgroup->root == &cgrp_dfl_root)
+ return 0;
+#endif
return sysctl_sched_rt_runtime >= 0;
}
--
2.25.1
Powered by blists - more mailing lists