aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorChristian Ehrhardt <ehrhardt@linux.vnet.ibm.com>2009-11-30 06:16:48 -0500
committerIngo Molnar <mingo@elte.hu>2009-12-09 04:04:02 -0500
commitacb4a848da821a095ae9e4d8b22ae2d9633ba5cd (patch)
tree152efff68841e554eb71c82a97d3ed9571352581 /kernel
parent1983a922a1bc843806b9a36cf3a370b242783140 (diff)
sched: Update normalized values on user updates via proc
The normalized values are also recalculated in case the scaling factor changes. This patch updates the internally used scheduler tuning values that are normalized to one cpu in case a user sets new values via sysfs. Together with patch 2 of this series this allows to let user configured values scale (or not) to cpu add/remove events taking place later. Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> LKML-Reference: <1259579808-11357-4-git-send-email-ehrhardt@linux.vnet.ibm.com> [ v2: fix warning ] Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c12
-rw-r--r--kernel/sched_fair.c11
-rw-r--r--kernel/sysctl.c14
3 files changed, 29 insertions, 8 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 116efed962c6..0a60e8e9b094 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -1816,6 +1816,7 @@ static void cfs_rq_set_shares(struct cfs_rq *cfs_rq, unsigned long shares)
1816 1816
1817static void calc_load_account_active(struct rq *this_rq); 1817static void calc_load_account_active(struct rq *this_rq);
1818static void update_sysctl(void); 1818static void update_sysctl(void);
1819static int get_update_sysctl_factor(void);
1819 1820
1820static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu) 1821static inline void __set_task_cpu(struct task_struct *p, unsigned int cpu)
1821{ 1822{
@@ -7030,9 +7031,9 @@ cpumask_var_t nohz_cpu_mask;
7030 * 7031 *
7031 * This idea comes from the SD scheduler of Con Kolivas: 7032 * This idea comes from the SD scheduler of Con Kolivas:
7032 */ 7033 */
7033static void update_sysctl(void) 7034static int get_update_sysctl_factor(void)
7034{ 7035{
7035 unsigned int cpus = min(num_online_cpus(), 8U); 7036 unsigned int cpus = min(num_online_cpus(), 8);
7036 unsigned int factor; 7037 unsigned int factor;
7037 7038
7038 switch (sysctl_sched_tunable_scaling) { 7039 switch (sysctl_sched_tunable_scaling) {
@@ -7048,6 +7049,13 @@ static void update_sysctl(void)
7048 break; 7049 break;
7049 } 7050 }
7050 7051
7052 return factor;
7053}
7054
7055static void update_sysctl(void)
7056{
7057 unsigned int factor = get_update_sysctl_factor();
7058
7051#define SET_SYSCTL(name) \ 7059#define SET_SYSCTL(name) \
7052 (sysctl_##name = (factor) * normalized_sysctl_##name) 7060 (sysctl_##name = (factor) * normalized_sysctl_##name)
7053 SET_SYSCTL(sched_min_granularity); 7061 SET_SYSCTL(sched_min_granularity);
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 455106d318a8..804a411838f1 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -399,11 +399,12 @@ static struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
399 */ 399 */
400 400
401#ifdef CONFIG_SCHED_DEBUG 401#ifdef CONFIG_SCHED_DEBUG
402int sched_nr_latency_handler(struct ctl_table *table, int write, 402int sched_proc_update_handler(struct ctl_table *table, int write,
403 void __user *buffer, size_t *lenp, 403 void __user *buffer, size_t *lenp,
404 loff_t *ppos) 404 loff_t *ppos)
405{ 405{
406 int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); 406 int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
407 int factor = get_update_sysctl_factor();
407 408
408 if (ret || !write) 409 if (ret || !write)
409 return ret; 410 return ret;
@@ -411,6 +412,14 @@ int sched_nr_latency_handler(struct ctl_table *table, int write,
411 sched_nr_latency = DIV_ROUND_UP(sysctl_sched_latency, 412 sched_nr_latency = DIV_ROUND_UP(sysctl_sched_latency,
412 sysctl_sched_min_granularity); 413 sysctl_sched_min_granularity);
413 414
415#define WRT_SYSCTL(name) \
416 (normalized_sysctl_##name = sysctl_##name / (factor))
417 WRT_SYSCTL(sched_min_granularity);
418 WRT_SYSCTL(sched_latency);
419 WRT_SYSCTL(sched_wakeup_granularity);
420 WRT_SYSCTL(sched_shares_ratelimit);
421#undef WRT_SYSCTL
422
414 return 0; 423 return 0;
415} 424}
416#endif 425#endif
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index d10406e5fdfe..b9e5a45f1e28 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -253,6 +253,8 @@ static 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; 254static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
255static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1; 255static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
256static int min_sched_shares_ratelimit = 100000; /* 100 usec */
257static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
256#endif 258#endif
257 259
258static struct ctl_table kern_table[] = { 260static struct ctl_table kern_table[] = {
@@ -271,7 +273,7 @@ static struct ctl_table kern_table[] = {
271 .data = &sysctl_sched_min_granularity, 273 .data = &sysctl_sched_min_granularity,
272 .maxlen = sizeof(unsigned int), 274 .maxlen = sizeof(unsigned int),
273 .mode = 0644, 275 .mode = 0644,
274 .proc_handler = &sched_nr_latency_handler, 276 .proc_handler = &sched_proc_update_handler,
275 .strategy = &sysctl_intvec, 277 .strategy = &sysctl_intvec,
276 .extra1 = &min_sched_granularity_ns, 278 .extra1 = &min_sched_granularity_ns,
277 .extra2 = &max_sched_granularity_ns, 279 .extra2 = &max_sched_granularity_ns,
@@ -282,7 +284,7 @@ static struct ctl_table kern_table[] = {
282 .data = &sysctl_sched_latency, 284 .data = &sysctl_sched_latency,
283 .maxlen = sizeof(unsigned int), 285 .maxlen = sizeof(unsigned int),
284 .mode = 0644, 286 .mode = 0644,
285 .proc_handler = &sched_nr_latency_handler, 287 .proc_handler = &sched_proc_update_handler,
286 .strategy = &sysctl_intvec, 288 .strategy = &sysctl_intvec,
287 .extra1 = &min_sched_granularity_ns, 289 .extra1 = &min_sched_granularity_ns,
288 .extra2 = &max_sched_granularity_ns, 290 .extra2 = &max_sched_granularity_ns,
@@ -293,7 +295,7 @@ static struct ctl_table kern_table[] = {
293 .data = &sysctl_sched_wakeup_granularity, 295 .data = &sysctl_sched_wakeup_granularity,
294 .maxlen = sizeof(unsigned int), 296 .maxlen = sizeof(unsigned int),
295 .mode = 0644, 297 .mode = 0644,
296 .proc_handler = &proc_dointvec_minmax, 298 .proc_handler = &sched_proc_update_handler,
297 .strategy = &sysctl_intvec, 299 .strategy = &sysctl_intvec,
298 .extra1 = &min_wakeup_granularity_ns, 300 .extra1 = &min_wakeup_granularity_ns,
299 .extra2 = &max_wakeup_granularity_ns, 301 .extra2 = &max_wakeup_granularity_ns,
@@ -304,7 +306,9 @@ static struct ctl_table kern_table[] = {
304 .data = &sysctl_sched_shares_ratelimit, 306 .data = &sysctl_sched_shares_ratelimit,
305 .maxlen = sizeof(unsigned int), 307 .maxlen = sizeof(unsigned int),
306 .mode = 0644, 308 .mode = 0644,
307 .proc_handler = &proc_dointvec, 309 .proc_handler = &sched_proc_update_handler,
310 .extra1 = &min_sched_shares_ratelimit,
311 .extra2 = &max_sched_shares_ratelimit,
308 }, 312 },
309 { 313 {
310 .ctl_name = CTL_UNNUMBERED, 314 .ctl_name = CTL_UNNUMBERED,
@@ -312,7 +316,7 @@ static struct ctl_table kern_table[] = {
312 .data = &sysctl_sched_tunable_scaling, 316 .data = &sysctl_sched_tunable_scaling,
313 .maxlen = sizeof(enum sched_tunable_scaling), 317 .maxlen = sizeof(enum sched_tunable_scaling),
314 .mode = 0644, 318 .mode = 0644,
315 .proc_handler = &proc_dointvec_minmax, 319 .proc_handler = &sched_proc_update_handler,
316 .strategy = &sysctl_intvec, 320 .strategy = &sysctl_intvec,
317 .extra1 = &min_sched_tunable_scaling, 321 .extra1 = &min_sched_tunable_scaling,
318 .extra2 = &max_sched_tunable_scaling, 322 .extra2 = &max_sched_tunable_scaling,