aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/sched.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index debb06a4a660..475e3fcab738 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8228,6 +8228,38 @@ static unsigned long to_ratio(u64 period, u64 runtime)
8228 return div64_64(runtime << 16, period); 8228 return div64_64(runtime << 16, period);
8229} 8229}
8230 8230
8231#ifdef CONFIG_CGROUP_SCHED
8232static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime)
8233{
8234 struct task_group *tgi, *parent = tg->parent;
8235 unsigned long total = 0;
8236
8237 if (!parent) {
8238 if (global_rt_period() < period)
8239 return 0;
8240
8241 return to_ratio(period, runtime) <
8242 to_ratio(global_rt_period(), global_rt_runtime());
8243 }
8244
8245 if (ktime_to_ns(parent->rt_bandwidth.rt_period) < period)
8246 return 0;
8247
8248 rcu_read_lock();
8249 list_for_each_entry_rcu(tgi, &parent->children, siblings) {
8250 if (tgi == tg)
8251 continue;
8252
8253 total += to_ratio(ktime_to_ns(tgi->rt_bandwidth.rt_period),
8254 tgi->rt_bandwidth.rt_runtime);
8255 }
8256 rcu_read_unlock();
8257
8258 return total + to_ratio(period, runtime) <
8259 to_ratio(ktime_to_ns(parent->rt_bandwidth.rt_period),
8260 parent->rt_bandwidth.rt_runtime);
8261}
8262#elif defined CONFIG_USER_SCHED
8231static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime) 8263static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime)
8232{ 8264{
8233 struct task_group *tgi; 8265 struct task_group *tgi;
@@ -8247,6 +8279,7 @@ static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime)
8247 8279
8248 return total + to_ratio(period, runtime) < global_ratio; 8280 return total + to_ratio(period, runtime) < global_ratio;
8249} 8281}
8282#endif
8250 8283
8251/* Must be called with tasklist_lock held */ 8284/* Must be called with tasklist_lock held */
8252static inline int tg_has_rt_tasks(struct task_group *tg) 8285static inline int tg_has_rt_tasks(struct task_group *tg)