aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2013-12-17 06:44:49 -0500
committerIngo Molnar <mingo@kernel.org>2014-01-13 07:47:23 -0500
commit1724813d9f2c7ff702b46d3e4a4f6d9b10a8f8c2 (patch)
tree6df01bd6de3641b7f62440e22cf1ac8020b82ce5
parente4099a5e929435cd6349343f002583f29868c900 (diff)
sched/deadline: Remove the sysctl_sched_dl knobs
Remove the deadline specific sysctls for now. The problem with them is that the interaction with the exisiting rt knobs is nearly impossible to get right. The current (as per before this patch) situation is that the rt and dl bandwidth is completely separate and we enforce rt+dl < 100%. This is undesirable because this means that the rt default of 95% leaves us hardly any room, even though dl tasks are saver than rt tasks. Another proposed solution was (a discarted patch) to have the dl bandwidth be a fraction of the rt bandwidth. This is highly confusing imo. Furthermore neither proposal is consistent with the situation we actually want; which is rt tasks ran from a dl server. In which case the rt bandwidth is a direct subset of dl. So whichever way we go, the introduction of dl controls at this point is painful. Therefore remove them and instead share the rt budget. This means that for now the rt knobs are used for dl admission control and the dl runtime is accounted against the rt runtime. I realise that this isn't entirely desirable either; but whatever we do we appear to need to change the interface later, so better have a small interface for now. Signed-off-by: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/n/tip-zpyqbqds1r0vyxtxza1e7rdc@git.kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--include/linux/sched/sysctl.h13
-rw-r--r--kernel/sched/core.c259
-rw-r--r--kernel/sched/deadline.c27
-rw-r--r--kernel/sched/sched.h18
-rw-r--r--kernel/sysctl.c14
5 files changed, 97 insertions, 234 deletions
diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
index 8070a83dbedc..31e0193cb0c5 100644
--- a/include/linux/sched/sysctl.h
+++ b/include/linux/sched/sysctl.h
@@ -81,15 +81,6 @@ static inline unsigned int get_sysctl_timer_migration(void)
81extern unsigned int sysctl_sched_rt_period; 81extern unsigned int sysctl_sched_rt_period;
82extern int sysctl_sched_rt_runtime; 82extern int sysctl_sched_rt_runtime;
83 83
84/*
85 * control SCHED_DEADLINE reservations:
86 *
87 * /proc/sys/kernel/sched_dl_period_us
88 * /proc/sys/kernel/sched_dl_runtime_us
89 */
90extern unsigned int sysctl_sched_dl_period;
91extern int sysctl_sched_dl_runtime;
92
93#ifdef CONFIG_CFS_BANDWIDTH 84#ifdef CONFIG_CFS_BANDWIDTH
94extern unsigned int sysctl_sched_cfs_bandwidth_slice; 85extern unsigned int sysctl_sched_cfs_bandwidth_slice;
95#endif 86#endif
@@ -108,8 +99,4 @@ extern int sched_rt_handler(struct ctl_table *table, int write,
108 void __user *buffer, size_t *lenp, 99 void __user *buffer, size_t *lenp,
109 loff_t *ppos); 100 loff_t *ppos);
110 101
111int sched_dl_handler(struct ctl_table *table, int write,
112 void __user *buffer, size_t *lenp,
113 loff_t *ppos);
114
115#endif /* _SCHED_SYSCTL_H */ 102#endif /* _SCHED_SYSCTL_H */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 27c6375d182a..1d33eb8143cc 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6771,7 +6771,7 @@ void __init sched_init(void)
6771 init_rt_bandwidth(&def_rt_bandwidth, 6771 init_rt_bandwidth(&def_rt_bandwidth,
6772 global_rt_period(), global_rt_runtime()); 6772 global_rt_period(), global_rt_runtime());
6773 init_dl_bandwidth(&def_dl_bandwidth, 6773 init_dl_bandwidth(&def_dl_bandwidth,
6774 global_dl_period(), global_dl_runtime()); 6774 global_rt_period(), global_rt_runtime());
6775 6775
6776#ifdef CONFIG_SMP 6776#ifdef CONFIG_SMP
6777 init_defrootdomain(); 6777 init_defrootdomain();
@@ -7354,64 +7354,11 @@ static long sched_group_rt_period(struct task_group *tg)
7354} 7354}
7355#endif /* CONFIG_RT_GROUP_SCHED */ 7355#endif /* CONFIG_RT_GROUP_SCHED */
7356 7356
7357/*
7358 * Coupling of -rt and -deadline bandwidth.
7359 *
7360 * Here we check if the new -rt bandwidth value is consistent
7361 * with the system settings for the bandwidth available
7362 * to -deadline tasks.
7363 *
7364 * IOW, we want to enforce that
7365 *
7366 * rt_bandwidth + dl_bandwidth <= 100%
7367 *
7368 * is always true.
7369 */
7370static bool __sched_rt_dl_global_constraints(u64 rt_bw)
7371{
7372 unsigned long flags;
7373 u64 dl_bw;
7374 bool ret;
7375
7376 raw_spin_lock_irqsave(&def_dl_bandwidth.dl_runtime_lock, flags);
7377 if (global_rt_runtime() == RUNTIME_INF ||
7378 global_dl_runtime() == RUNTIME_INF) {
7379 ret = true;
7380 goto unlock;
7381 }
7382
7383 dl_bw = to_ratio(def_dl_bandwidth.dl_period,
7384 def_dl_bandwidth.dl_runtime);
7385
7386 ret = rt_bw + dl_bw <= to_ratio(RUNTIME_INF, RUNTIME_INF);
7387unlock:
7388 raw_spin_unlock_irqrestore(&def_dl_bandwidth.dl_runtime_lock, flags);
7389
7390 return ret;
7391}
7392
7393#ifdef CONFIG_RT_GROUP_SCHED 7357#ifdef CONFIG_RT_GROUP_SCHED
7394static int sched_rt_global_constraints(void) 7358static int sched_rt_global_constraints(void)
7395{ 7359{
7396 u64 runtime, period, bw;
7397 int ret = 0; 7360 int ret = 0;
7398 7361
7399 if (sysctl_sched_rt_period <= 0)
7400 return -EINVAL;
7401
7402 runtime = global_rt_runtime();
7403 period = global_rt_period();
7404
7405 /*
7406 * Sanity check on the sysctl variables.
7407 */
7408 if (runtime > period && runtime != RUNTIME_INF)
7409 return -EINVAL;
7410
7411 bw = to_ratio(period, runtime);
7412 if (!__sched_rt_dl_global_constraints(bw))
7413 return -EINVAL;
7414
7415 mutex_lock(&rt_constraints_mutex); 7362 mutex_lock(&rt_constraints_mutex);
7416 read_lock(&tasklist_lock); 7363 read_lock(&tasklist_lock);
7417 ret = __rt_schedulable(NULL, 0, 0); 7364 ret = __rt_schedulable(NULL, 0, 0);
@@ -7435,18 +7382,8 @@ static int sched_rt_global_constraints(void)
7435{ 7382{
7436 unsigned long flags; 7383 unsigned long flags;
7437 int i, ret = 0; 7384 int i, ret = 0;
7438 u64 bw;
7439
7440 if (sysctl_sched_rt_period <= 0)
7441 return -EINVAL;
7442 7385
7443 raw_spin_lock_irqsave(&def_rt_bandwidth.rt_runtime_lock, flags); 7386 raw_spin_lock_irqsave(&def_rt_bandwidth.rt_runtime_lock, flags);
7444 bw = to_ratio(global_rt_period(), global_rt_runtime());
7445 if (!__sched_rt_dl_global_constraints(bw)) {
7446 ret = -EINVAL;
7447 goto unlock;
7448 }
7449
7450 for_each_possible_cpu(i) { 7387 for_each_possible_cpu(i) {
7451 struct rt_rq *rt_rq = &cpu_rq(i)->rt; 7388 struct rt_rq *rt_rq = &cpu_rq(i)->rt;
7452 7389
@@ -7454,69 +7391,18 @@ static int sched_rt_global_constraints(void)
7454 rt_rq->rt_runtime = global_rt_runtime(); 7391 rt_rq->rt_runtime = global_rt_runtime();
7455 raw_spin_unlock(&rt_rq->rt_runtime_lock); 7392 raw_spin_unlock(&rt_rq->rt_runtime_lock);
7456 } 7393 }
7457unlock:
7458 raw_spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags); 7394 raw_spin_unlock_irqrestore(&def_rt_bandwidth.rt_runtime_lock, flags);
7459 7395
7460 return ret; 7396 return ret;
7461} 7397}
7462#endif /* CONFIG_RT_GROUP_SCHED */ 7398#endif /* CONFIG_RT_GROUP_SCHED */
7463 7399
7464/*
7465 * Coupling of -dl and -rt bandwidth.
7466 *
7467 * Here we check, while setting the system wide bandwidth available
7468 * for -dl tasks and groups, if the new values are consistent with
7469 * the system settings for the bandwidth available to -rt entities.
7470 *
7471 * IOW, we want to enforce that
7472 *
7473 * rt_bandwidth + dl_bandwidth <= 100%
7474 *
7475 * is always true.
7476 */
7477static bool __sched_dl_rt_global_constraints(u64 dl_bw)
7478{
7479 u64 rt_bw;
7480 bool ret;
7481
7482 raw_spin_lock(&def_rt_bandwidth.rt_runtime_lock);
7483 if (global_dl_runtime() == RUNTIME_INF ||
7484 global_rt_runtime() == RUNTIME_INF) {
7485 ret = true;
7486 goto unlock;
7487 }
7488
7489 rt_bw = to_ratio(ktime_to_ns(def_rt_bandwidth.rt_period),
7490 def_rt_bandwidth.rt_runtime);
7491
7492 ret = rt_bw + dl_bw <= to_ratio(RUNTIME_INF, RUNTIME_INF);
7493unlock:
7494 raw_spin_unlock(&def_rt_bandwidth.rt_runtime_lock);
7495
7496 return ret;
7497}
7498
7499static bool __sched_dl_global_constraints(u64 runtime, u64 period)
7500{
7501 if (!period || (runtime != RUNTIME_INF && runtime > period))
7502 return -EINVAL;
7503
7504 return 0;