diff options
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index 669c49aa57f0..e1299de1765e 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -8866,11 +8866,29 @@ static int tg_schedulable(struct task_group *tg, void *data) | |||
8866 | runtime = d->rt_runtime; | 8866 | runtime = d->rt_runtime; |
8867 | } | 8867 | } |
8868 | 8868 | ||
8869 | /* | ||
8870 | * Cannot have more runtime than the period. | ||
8871 | */ | ||
8872 | if (runtime > period && runtime != RUNTIME_INF) | ||
8873 | return -EINVAL; | ||
8874 | |||
8875 | /* | ||
8876 | * Ensure we don't starve existing RT tasks. | ||
8877 | */ | ||
8869 | if (rt_bandwidth_enabled() && !runtime && tg_has_rt_tasks(tg)) | 8878 | if (rt_bandwidth_enabled() && !runtime && tg_has_rt_tasks(tg)) |
8870 | return -EBUSY; | 8879 | return -EBUSY; |
8871 | 8880 | ||
8872 | total = to_ratio(period, runtime); | 8881 | total = to_ratio(period, runtime); |
8873 | 8882 | ||
8883 | /* | ||
8884 | * Nobody can have more than the global setting allows. | ||
8885 | */ | ||
8886 | if (total > to_ratio(global_rt_period(), global_rt_runtime())) | ||
8887 | return -EINVAL; | ||
8888 | |||
8889 | /* | ||
8890 | * The sum of our children's runtime should not exceed our own. | ||
8891 | */ | ||
8874 | list_for_each_entry_rcu(child, &tg->children, siblings) { | 8892 | list_for_each_entry_rcu(child, &tg->children, siblings) { |
8875 | period = ktime_to_ns(child->rt_bandwidth.rt_period); | 8893 | period = ktime_to_ns(child->rt_bandwidth.rt_period); |
8876 | runtime = child->rt_bandwidth.rt_runtime; | 8894 | runtime = child->rt_bandwidth.rt_runtime; |
@@ -8978,19 +8996,24 @@ long sched_group_rt_period(struct task_group *tg) | |||
8978 | 8996 | ||
8979 | static int sched_rt_global_constraints(void) | 8997 | static int sched_rt_global_constraints(void) |
8980 | { | 8998 | { |
8981 | struct task_group *tg = &root_task_group; | 8999 | u64 runtime, period; |
8982 | u64 rt_runtime, rt_period; | ||
8983 | int ret = 0; | 9000 | int ret = 0; |
8984 | 9001 | ||
8985 | if (sysctl_sched_rt_period <= 0) | 9002 | if (sysctl_sched_rt_period <= 0) |
8986 | return -EINVAL; | 9003 | return -EINVAL; |
8987 | 9004 | ||
8988 | rt_period = ktime_to_ns(tg->rt_bandwidth.rt_period); | 9005 | runtime = global_rt_runtime(); |
8989 | rt_runtime = tg->rt_bandwidth.rt_runtime; | 9006 | period = global_rt_period(); |
9007 | |||
9008 | /* | ||
9009 | * Sanity check on the sysctl variables. | ||
9010 | */ | ||
9011 | if (runtime > period && runtime != RUNTIME_INF) | ||
9012 | return -EINVAL; | ||
8990 | 9013 | ||
8991 | mutex_lock(&rt_constraints_mutex); | 9014 | mutex_lock(&rt_constraints_mutex); |
8992 | read_lock(&tasklist_lock); | 9015 | read_lock(&tasklist_lock); |
8993 | ret = __rt_schedulable(tg, rt_period, rt_runtime); | 9016 | ret = __rt_schedulable(NULL, 0, 0); |
8994 | read_unlock(&tasklist_lock); | 9017 | read_unlock(&tasklist_lock); |
8995 | mutex_unlock(&rt_constraints_mutex); | 9018 | mutex_unlock(&rt_constraints_mutex); |
8996 | 9019 | ||