From 1cc8729ba0eae4ee13005f93676a61cf9b6bd8be Mon Sep 17 00:00:00 2001 From: Dhaval Giani Date: Thu, 28 Feb 2008 15:21:56 +0530 Subject: [PATCH] --- yaml --- r: 87035 b: refs/heads/master c: 521f1a2489c41f8b1181b0a8eb52e1c34284d50b h: refs/heads/master i: 87033: f108b31d78be44900f53433282478f0feee83fc7 87031: 822696eb003bb63a1d844eb034fbdca0550d86ef v: v3 --- [refs] | 2 +- trunk/kernel/sched.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index e10a155dcfb9..689d516bf021 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 2692a2406b9262bbb101708815be99ec2988e48b +refs/heads/master: 521f1a2489c41f8b1181b0a8eb52e1c34284d50b diff --git a/trunk/kernel/sched.c b/trunk/kernel/sched.c index b8ee864c7481..52b98675acb2 100644 --- a/trunk/kernel/sched.c +++ b/trunk/kernel/sched.c @@ -7750,6 +7750,17 @@ static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime) 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) { u64 rt_runtime, rt_period; @@ -7761,12 +7772,18 @@ int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us) rt_runtime = RUNTIME_INF; 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)) { err = -EINVAL; goto unlock; } tg->rt_runtime = rt_runtime; unlock: + read_unlock(&tasklist_lock); mutex_unlock(&rt_constraints_mutex); return err;