[PATCH 5/5] sched, autogroup: runtime enable/disable tuning fix
From: Yong Zhang
Date: Sun Feb 20 2011 - 02:09:05 EST
Now enable/disable autogroup at runtime is just a flag,
it doesn't take effect on current process of the system.
when disable autogroup:
vanilla:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1046 test1 20 0 25544 844 276 R 50.0 0.0 0:23.30 bash
1044 test2 20 0 25544 860 280 R 25.2 0.0 0:20.55 bash
1045 test2 20 0 25544 864 284 R 24.8 0.0 0:17.48 bash
patched:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
991 test1 20 0 25544 844 276 R 31.7 0.0 2:05.93 bash
992 test2 20 0 25544 848 276 R 31.7 0.0 1:16.84 bash
994 test2 20 0 25544 856 284 R 29.8 0.0 1:02.67 bash
Signed-off-by: Yong Zhang <yong.zhang0@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
---
include/linux/sched.h | 3 +++
kernel/sched_autogroup.c | 34 ++++++++++++++++++++++++++++++++++
kernel/sysctl.c | 2 +-
3 files changed, 38 insertions(+), 1 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index d747f94..00791ce 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1949,6 +1949,9 @@ extern unsigned int sysctl_sched_compat_yield;
#ifdef CONFIG_SCHED_AUTOGROUP
extern unsigned int sysctl_sched_autogroup_enabled;
+extern int sysctl_sched_autogroup_handler(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp,
+ loff_t *ppos);
extern void sched_autogroup_create_attach(struct task_struct *p);
extern void sched_autogroup_detach(struct task_struct *p);
diff --git a/kernel/sched_autogroup.c b/kernel/sched_autogroup.c
index 137a096..b1ad946 100644
--- a/kernel/sched_autogroup.c
+++ b/kernel/sched_autogroup.c
@@ -211,6 +211,40 @@ static int __init setup_autogroup(char *str)
__setup("noautogroup", setup_autogroup);
+static DEFINE_MUTEX(autogroup_sysctl_mutex);
+
+int sysctl_sched_autogroup_handler(struct ctl_table *table, int write,
+ void __user *buffer, size_t *lenp,
+ loff_t *ppos)
+{
+ int old_value, ret;
+ struct task_struct *p, *n;
+
+ mutex_lock(&autogroup_sysctl_mutex);
+
+ old_value = sysctl_sched_autogroup_enabled;
+ ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
+
+ if (ret || !write || (old_value == sysctl_sched_autogroup_enabled))
+ goto out_unlock;
+
+ read_lock_irq(&tasklist_lock);
+ rcu_read_lock();
+
+ do_each_thread(n, p) {
+ if (cgroup_task_group(p) == &root_task_group)
+ sched_move_task(p);
+ } while_each_thread(n, p);
+
+ rcu_read_unlock();
+ read_unlock_irq(&tasklist_lock);
+
+out_unlock:
+ mutex_unlock(&autogroup_sysctl_mutex);
+
+ return ret;
+}
+
#ifdef CONFIG_PROC_FS
int proc_sched_autogroup_set_nice(struct task_struct *p, int *nice)
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 22e07ee..2b12c65 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -374,7 +374,7 @@ static struct ctl_table kern_table[] = {
.data = &sysctl_sched_autogroup_enabled,
.maxlen = sizeof(unsigned int),
.mode = 0644,
- .proc_handler = proc_dointvec_minmax,
+ .proc_handler = sysctl_sched_autogroup_handler,
.extra1 = &zero,
.extra2 = &one,
},
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/