Skip to content

Commit

Permalink
sched: rt-group: refure unrunnable tasks
Browse files Browse the repository at this point in the history
Refuse to accept or create RT tasks in groups that can't run them.

Signed-off-by: Peter Zijlstra <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Feb 13, 2008
1 parent bccbe08 commit b68aa23
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -4584,6 +4584,15 @@ int sched_setscheduler(struct task_struct *p, int policy,
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);
if (retval)
return retval;
Expand Down Expand Up @@ -8028,9 +8037,15 @@ static int
cpu_cgroup_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp,
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 */
if (tsk->sched_class != &fair_sched_class)
return -EINVAL;
#endif

return 0;
}
Expand Down

0 comments on commit b68aa23

Please sign in to comment.