Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 110730
b: refs/heads/master
c: 4653f80
h: refs/heads/master
v: v3
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Sep 23, 2008
1 parent 9d14bf5 commit 1cedda4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 78333cdd0e472180743d35988e576d6ecc6f6ddb
refs/heads/master: 4653f803e6e0d970ffeac0efd2c01743eb6c5228
33 changes: 28 additions & 5 deletions trunk/kernel/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -8866,11 +8866,29 @@ static int tg_schedulable(struct task_group *tg, void *data)
runtime = d->rt_runtime;
}

/*
* Cannot have more runtime than the period.
*/
if (runtime > period && runtime != RUNTIME_INF)
return -EINVAL;

/*
* Ensure we don't starve existing RT tasks.
*/
if (rt_bandwidth_enabled() && !runtime && tg_has_rt_tasks(tg))
return -EBUSY;

total = to_ratio(period, runtime);

/*
* Nobody can have more than the global setting allows.
*/
if (total > to_ratio(global_rt_period(), global_rt_runtime()))
return -EINVAL;

/*
* The sum of our children's runtime should not exceed our own.
*/
list_for_each_entry_rcu(child, &tg->children, siblings) {
period = ktime_to_ns(child->rt_bandwidth.rt_period);
runtime = child->rt_bandwidth.rt_runtime;
Expand Down Expand Up @@ -8978,19 +8996,24 @@ long sched_group_rt_period(struct task_group *tg)

static int sched_rt_global_constraints(void)
{
struct task_group *tg = &root_task_group;
u64 rt_runtime, rt_period;
u64 runtime, period;
int ret = 0;

if (sysctl_sched_rt_period <= 0)
return -EINVAL;

rt_period = ktime_to_ns(tg->rt_bandwidth.rt_period);
rt_runtime = tg->rt_bandwidth.rt_runtime;
runtime = global_rt_runtime();
period = global_rt_period();

/*
* Sanity check on the sysctl variables.
*/
if (runtime > period && runtime != RUNTIME_INF)
return -EINVAL;

mutex_lock(&rt_constraints_mutex);
read_lock(&tasklist_lock);
ret = __rt_schedulable(tg, rt_period, rt_runtime);
ret = __rt_schedulable(NULL, 0, 0);
read_unlock(&tasklist_lock);
mutex_unlock(&rt_constraints_mutex);

Expand Down

0 comments on commit 1cedda4

Please sign in to comment.