浏览代码

sched: rt-group: refure unrunnable tasks

Refuse to accept or create RT tasks in groups that can't run them.

Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Peter Zijlstra 17 年之前
父节点
当前提交
b68aa2300c
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      kernel/sched.c

+ 15 - 0
kernel/sched.c

@@ -4584,6 +4584,15 @@ recheck:
 			return -EPERM;
 			return -EPERM;
 	}
 	}
 
 
+#ifdef CONFIG_RT_GROUP_SCHED
+	/*
+	 * Do not allow realtime tasks into groups that have no runtime
+	 * assigned.
+	 */
+	if (rt_policy(policy) && task_group(p)->rt_runtime == 0)
+		return -EPERM;
+#endif
+
 	retval = security_task_setscheduler(p, policy, param);
 	retval = security_task_setscheduler(p, policy, param);
 	if (retval)
 	if (retval)
 		return retval;
 		return retval;
@@ -8028,9 +8037,15 @@ static int
 cpu_cgroup_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
 cpu_cgroup_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
 		      struct task_struct *tsk)
 		      struct task_struct *tsk)
 {
 {
+#ifdef CONFIG_RT_GROUP_SCHED
+	/* Don't accept realtime tasks when there is no way for them to run */
+	if (rt_task(tsk) && cgroup_tg(cgrp)->rt_runtime == 0)
+		return -EINVAL;
+#else
 	/* We don't support RT-tasks being in separate groups */
 	/* We don't support RT-tasks being in separate groups */
 	if (tsk->sched_class != &fair_sched_class)
 	if (tsk->sched_class != &fair_sched_class)
 		return -EINVAL;
 		return -EINVAL;
+#endif
 
 
 	return 0;
 	return 0;
 }
 }