]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched: Bypass bandwitdh checks with runtime disabled RT_GROUP_SCHED
authorMichal Koutný <mkoutny@suse.com>
Mon, 10 Mar 2025 17:04:38 +0000 (18:04 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 8 Apr 2025 18:55:54 +0000 (20:55 +0200)
When RT_GROUPs are compiled but not exposed, their bandwidth cannot
be configured (and it is not initialized for non-root task_groups neither).
Therefore bypass any checks of task vs task_group bandwidth.

This will achieve behavior very similar to setups that have
!CONFIG_RT_GROUP_SCHED and attach cpu controller to cgroup v2 hierarchy.
(On a related note, this may allow having RT tasks with
CONFIG_RT_GROUP_SCHED and cgroup v2 hierarchy.)

Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20250310170442.504716-7-mkoutny@suse.com
kernel/sched/core.c
kernel/sched/rt.c
kernel/sched/syscalls.c

index 32fb4c1100cb985e3d2f4f3a480e04b735b059f2..6900ce5b90398c4072c8fb4fc0b08b72a3181817 100644 (file)
@@ -9206,11 +9206,15 @@ static int cpu_cgroup_can_attach(struct cgroup_taskset *tset)
        struct task_struct *task;
        struct cgroup_subsys_state *css;
 
+       if (!rt_group_sched_enabled())
+               goto scx_check;
+
        cgroup_taskset_for_each(task, css, tset) {
                if (!sched_rt_can_attach(css_tg(css), task))
                        return -EINVAL;
        }
-#endif
+scx_check:
+#endif /* CONFIG_RT_GROUP_SCHED */
        return scx_cgroup_can_attach(tset);
 }
 
index efa22bad31e1afcae43cb22ce7412ab7401e59ab..5e82bfe56fdf9fa803d2bca16561f511e120493a 100644 (file)
@@ -2864,7 +2864,7 @@ static int sched_rt_global_constraints(void)
 int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk)
 {
        /* Don't accept real-time tasks when there is no way for them to run */
-       if (rt_task(tsk) && tg->rt_bandwidth.rt_runtime == 0)
+       if (rt_group_sched_enabled() && rt_task(tsk) && tg->rt_bandwidth.rt_runtime == 0)
                return 0;
 
        return 1;
index 2bf528116fad2d5e52bc41517c1255acc85ee19f..547c1f05b667ef1a381989bb984015c7c3838344 100644 (file)
@@ -634,7 +634,8 @@ change:
                 * Do not allow real-time tasks into groups that have no runtime
                 * assigned.
                 */
-               if (rt_bandwidth_enabled() && rt_policy(policy) &&
+               if (rt_group_sched_enabled() &&
+                               rt_bandwidth_enabled() && rt_policy(policy) &&
                                task_group(p)->rt_bandwidth.rt_runtime == 0 &&
                                !task_group_is_autogroup(task_group(p))) {
                        retval = -EPERM;