Commit 521f1a24 authored by Dhaval Giani's avatar Dhaval Giani Committed by Ingo Molnar

sched: don't allow rt_runtime_us to be zero for groups having rt tasks

This patch checks if we can set the rt_runtime_us to 0. If there is a
realtime task in the group, we don't want to set the rt_runtime_us as 0
or bad things will happen. (that task wont get any CPU time despite
being TASK_RUNNNG)
Signed-off-by: default avatarDhaval Giani <dhaval@linux.vnet.ibm.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 2692a240
...@@ -7750,6 +7750,17 @@ static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime) ...@@ -7750,6 +7750,17 @@ static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime)
return total + to_ratio(period, runtime) < global_ratio; return total + to_ratio(period, runtime) < global_ratio;
} }
/* Must be called with tasklist_lock held */
static inline int tg_has_rt_tasks(struct task_group *tg)
{
struct task_struct *g, *p;
do_each_thread(g, p) {
if (rt_task(p) && rt_rq_of_se(&p->rt)->tg == tg)
return 1;
} while_each_thread(g, p);
return 0;
}
int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us) int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
{ {
u64 rt_runtime, rt_period; u64 rt_runtime, rt_period;
...@@ -7761,12 +7772,18 @@ int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us) ...@@ -7761,12 +7772,18 @@ int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us)
rt_runtime = RUNTIME_INF; rt_runtime = RUNTIME_INF;
mutex_lock(&rt_constraints_mutex); mutex_lock(&rt_constraints_mutex);
read_lock(&tasklist_lock);
if (rt_runtime_us == 0 && tg_has_rt_tasks(tg)) {
err = -EBUSY;
goto unlock;
}
if (!__rt_schedulable(tg, rt_period, rt_runtime)) { if (!__rt_schedulable(tg, rt_period, rt_runtime)) {
err = -EINVAL; err = -EINVAL;
goto unlock; goto unlock;
} }
tg->rt_runtime = rt_runtime; tg->rt_runtime = rt_runtime;
unlock: unlock:
read_unlock(&tasklist_lock);
mutex_unlock(&rt_constraints_mutex); mutex_unlock(&rt_constraints_mutex);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment