Skip to content

Commit 277e090

Browse files
WerkovPeter Zijlstra
authored andcommitted
sched: Bypass bandwitdh checks with runtime disabled RT_GROUP_SCHED
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ý <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 61d3164 commit 277e090

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

kernel/sched/core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9206,11 +9206,15 @@ static int cpu_cgroup_can_attach(struct cgroup_taskset *tset)
92069206
struct task_struct *task;
92079207
struct cgroup_subsys_state *css;
92089208

9209+
if (!rt_group_sched_enabled())
9210+
goto scx_check;
9211+
92099212
cgroup_taskset_for_each(task, css, tset) {
92109213
if (!sched_rt_can_attach(css_tg(css), task))
92119214
return -EINVAL;
92129215
}
9213-
#endif
9216+
scx_check:
9217+
#endif /* CONFIG_RT_GROUP_SCHED */
92149218
return scx_cgroup_can_attach(tset);
92159219
}
92169220

kernel/sched/rt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,7 @@ static int sched_rt_global_constraints(void)
28642864
int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk)
28652865
{
28662866
/* Don't accept real-time tasks when there is no way for them to run */
2867-
if (rt_task(tsk) && tg->rt_bandwidth.rt_runtime == 0)
2867+
if (rt_group_sched_enabled() && rt_task(tsk) && tg->rt_bandwidth.rt_runtime == 0)
28682868
return 0;
28692869

28702870
return 1;

kernel/sched/syscalls.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,8 @@ int __sched_setscheduler(struct task_struct *p,
634634
* Do not allow real-time tasks into groups that have no runtime
635635
* assigned.
636636
*/
637-
if (rt_bandwidth_enabled() && rt_policy(policy) &&
637+
if (rt_group_sched_enabled() &&
638+
rt_bandwidth_enabled() && rt_policy(policy) &&
638639
task_group(p)->rt_bandwidth.rt_runtime == 0 &&
639640
!task_group_is_autogroup(task_group(p))) {
640641
retval = -EPERM;

0 commit comments

Comments
 (0)