diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2008-04-19 13:45:00 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-19 13:45:00 -0400 |
commit | b40b2e8eb52192a8a22d707ed37925792b7bdfd1 (patch) | |
tree | 88a20a3fc5a3d80ad7f5db4cd26255e14fd82642 /kernel | |
parent | f473aa5e025bc8e0c5fe9352f65178a54adadec2 (diff) |
sched: rt: multi level group constraints
multi level rt constraints
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/sched.c | 33 |
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 | ||
8232 | static 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 | ||
8231 | static int __rt_schedulable(struct task_group *tg, u64 period, u64 runtime) | 8263 | static 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 */ |
8252 | static inline int tg_has_rt_tasks(struct task_group *tg) | 8285 | static inline int tg_has_rt_tasks(struct task_group *tg) |