aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorChristian Ehrhardt <ehrhardt@linux.vnet.ibm.com>2009-11-30 06:16:47 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-09 04:04:01 -0500
commit1983a922a1bc843806b9a36cf3a370b242783140 (patch)
tree3071f23d39e05587823a40033c4c11a0867dd46e /kernel
parent0bcdcf28c979869f44e05121b96ff2cfb05bd8e6 (diff)
sched: Make tunable scaling style configurable
As scaling now takes place on all kind of cpu add/remove events a user that configures values via proc should be able to configure if his set values are still rescaled or kept whatever happens. As the comments state that log2 was just a second guess that worked the interface is not just designed for on/off, but to choose a scaling type. Currently this allows none, log and linear, but more important it allwos us to keep the interface even if someone has an even better idea how to scale the values. Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1259579808-11357-3-git-send-email-ehrhardt@linux.vnet.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c15
-rw-r--r--kernel/sched_debug.c10
-rw-r--r--kernel/sched_fair.c13
-rw-r--r--kernel/sysctl.c14
4 files changed, 51 insertions, 1 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index b54ecf84b6be..116efed962c6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7033,7 +7033,20 @@ cpumask_var_t nohz_cpu_mask;
7033static void update_sysctl(void) 7033static void update_sysctl(void)
7034{ 7034{
7035 unsigned int cpus = min(num_online_cpus(), 8U); 7035 unsigned int cpus = min(num_online_cpus(), 8U);
7036 unsigned int factor = 1 + ilog2(cpus); 7036 unsigned int factor;
7037
7038 switch (sysctl_sched_tunable_scaling) {
7039 case SCHED_TUNABLESCALING_NONE:
7040 factor = 1;
7041 break;
7042 case SCHED_TUNABLESCALING_LINEAR:
7043 factor = cpus;
7044 break;
7045 case SCHED_TUNABLESCALING_LOG:
7046 default:
7047 factor = 1 + ilog2(cpus);
7048 break;
7049 }
7037 7050
7038#define SET_SYSCTL(name) \ 7051#define SET_SYSCTL(name) \
7039 (sysctl_##name = (factor) * normalized_sysctl_##name) 7052 (sysctl_##name = (factor) * normalized_sysctl_##name)
diff --git a/kernel/sched_debug.c b/kernel/sched_debug.c
index 5fda66615fee..0fc5287fe80f 100644
--- a/kernel/sched_debug.c
+++ b/kernel/sched_debug.c
@@ -309,6 +309,12 @@ static void print_cpu(struct seq_file *m, int cpu)
309 print_rq(m, rq, cpu); 309 print_rq(m, rq, cpu);
310} 310}
311 311
312static const char *sched_tunable_scaling_names[] = {
313 "none",
314 "logaritmic",
315 "linear"
316};
317
312static int sched_debug_show(struct seq_file *m, void *v) 318static int sched_debug_show(struct seq_file *m, void *v)
313{ 319{
314 u64 now = ktime_to_ns(ktime_get()); 320 u64 now = ktime_to_ns(ktime_get());
@@ -334,6 +340,10 @@ static int sched_debug_show(struct seq_file *m, void *v)
334#undef PN 340#undef PN
335#undef P 341#undef P
336 342
343 SEQ_printf(m, " .%-40s: %d (%s)\n", "sysctl_sched_tunable_scaling",
344 sysctl_sched_tunable_scaling,
345 sched_tunable_scaling_names[sysctl_sched_tunable_scaling]);
346
337 for_each_online_cpu(cpu) 347 for_each_online_cpu(cpu)
338 print_cpu(m, cpu); 348 print_cpu(m, cpu);
339 349
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 71b3458245e5..455106d318a8 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -21,6 +21,7 @@
21 */ 21 */
22 22
23#include <linux/latencytop.h> 23#include <linux/latencytop.h>
24#include <linux/sched.h>
24 25
25/* 26/*
26 * Targeted preemption latency for CPU-bound tasks: 27 * Targeted preemption latency for CPU-bound tasks:
@@ -38,6 +39,18 @@ unsigned int sysctl_sched_latency = 5000000ULL;
38unsigned int normalized_sysctl_sched_latency = 5000000ULL; 39unsigned int normalized_sysctl_sched_latency = 5000000ULL;
39 40
40/* 41/*
42 * The initial- and re-scaling of tunables is configurable
43 * (default SCHED_TUNABLESCALING_LOG = *(1+ilog(ncpus))
44 *
45 * Options are:
46 * SCHED_TUNABLESCALING_NONE - unscaled, always *1
47 * SCHED_TUNABLESCALING_LOG - scaled logarithmical, *1+ilog(ncpus)
48 * SCHED_TUNABLESCALING_LINEAR - scaled linear, *ncpus
49 */
50enum sched_tunable_scaling sysctl_sched_tunable_scaling
51 = SCHED_TUNABLESCALING_LOG;
52
53/*
41 * Minimal preemption granularity for CPU-bound tasks: 54 * Minimal preemption granularity for CPU-bound tasks:
42 * (default: 1 msec * (1 + ilog(ncpus)), units: nanoseconds) 55 * (default: 1 msec * (1 + ilog(ncpus)), units: nanoseconds)
43 */ 56 */
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index e5cc53514caa..d10406e5fdfe 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -251,6 +251,8 @@ static int min_sched_granularity_ns = 100000; /* 100 usecs */
251static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */ 251static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
252static int min_wakeup_granularity_ns; /* 0 usecs */ 252static int min_wakeup_granularity_ns; /* 0 usecs */
253static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */ 253static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
254static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
255static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
254#endif 256#endif
255 257
256static struct ctl_table kern_table[] = { 258static struct ctl_table kern_table[] = {
@@ -306,6 +308,18 @@ static struct ctl_table kern_table[] = {
306 }, 308 },
307 { 309 {
308 .ctl_name = CTL_UNNUMBERED, 310 .ctl_name = CTL_UNNUMBERED,
311 .procname = "sched_tunable_scaling",
312 .data = &sysctl_sched_tunable_scaling,
313 .maxlen = sizeof(enum sched_tunable_scaling),
314 .mode = 0644,
315 .proc_handler = &proc_dointvec_minmax,
316 .strategy = &sysctl_intvec,
317 .extra1 = &min_sched_tunable_scaling,
318 .extra2 = &max_sched_tunable_scaling,
319 },
320
321 {
322 .ctl_name = CTL_UNNUMBERED,
309 .procname = "sched_shares_thresh", 323 .procname = "sched_shares_thresh",
310 .data = &sysctl_sched_shares_thresh, 324 .data = &sysctl_sched_shares_thresh,
311 .maxlen = sizeof(unsigned int), 325 .maxlen = sizeof(unsigned int),