diff options
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index b8ee864c7481..52b98675acb2 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -7750,6 +7750,17 @@ static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime) | |||
7750 | return total + to_ratio(period, runtime) < global_ratio; | 7750 | return total + to_ratio(period, runtime) < global_ratio; |
7751 | } | 7751 | } |
7752 | 7752 | ||
7753 | /* Must be called with tasklist_lock held */ | ||
7754 | static inline int tg_has_rt_tasks(struct task_group *tg) | ||
7755 | { | ||
7756 | struct task_struct *g, *p; | ||
7757 | do_each_thread(g, p) { | ||
7758 | if (rt_task(p) && rt_rq_of_se(&p->rt)->tg == tg) | ||
7759 | return 1; | ||
7760 | } while_each_thread(g, p); | ||
7761 | return 0; | ||
7762 | } | ||
7763 | |||
7753 | int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us) | 7764 | int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us) |
7754 | { | 7765 | { |
7755 | u64 rt_runtime, rt_period; | 7766 | u64 rt_runtime, rt_period; |
@@ -7761,12 +7772,18 @@ int sched_group_set_rt_runtime(struct task_group *tg, long rt_runtime_us) | |||
7761 | rt_runtime = RUNTIME_INF; | 7772 | rt_runtime = RUNTIME_INF; |
7762 | 7773 | ||
7763 | mutex_lock(&rt_constraints_mutex); | 7774 | mutex_lock(&rt_constraints_mutex); |
7775 | read_lock(&tasklist_lock); | ||
7776 | if (rt_runtime_us == 0 && tg_has_rt_tasks(tg)) { | ||
7777 | err = -EBUSY; | ||
7778 | goto unlock; | ||
7779 | } | ||
7764 | if (!__rt_schedulable(tg, rt_period, rt_runtime)) { | 7780 | if (!__rt_schedulable(tg, rt_period, rt_runtime)) { |
7765 | err = -EINVAL; | 7781 | err = -EINVAL; |
7766 | goto unlock; | 7782 | goto unlock; |
7767 | } | 7783 | } |
7768 | tg->rt_runtime = rt_runtime; | 7784 | tg->rt_runtime = rt_runtime; |
7769 | unlock: | 7785 | unlock: |
7786 | read_unlock(&tasklist_lock); | ||
7770 | mutex_unlock(&rt_constraints_mutex); | 7787 | mutex_unlock(&rt_constraints_mutex); |
7771 | 7788 | ||
7772 | return err; | 7789 | return err; |