mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yong Zhang <yong.zhang0@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <peterz@infradead.org>,
	Mike Galbraith <efault@gmx.de>
Subject: [PATCH 5/5] sched, autogroup: runtime enable/disable tuning fix
Date: Sun, 20 Feb 2011 15:08:16 +0800	[thread overview]
Message-ID: <1298185696-4403-6-git-send-email-yong.zhang0@gmail.com> (raw)
In-Reply-To: <1298185696-4403-1-git-send-email-yong.zhang0@gmail.com>

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@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
---
 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


  parent reply	other threads:[~2011-02-20  7:08 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-20  7:08 [PATCH 0/5] autogroup " Yong Zhang
2011-02-20  7:08 ` [PATCH 1/5] sched, autogroup, sysctl: use proc_dointvec_minmax instead Yong Zhang
2011-02-23 12:05   ` [tip:sched/core] sched, autogroup, sysctl: Use proc_dointvec_minmax() instead tip-bot for Yong Zhang
2011-02-20  7:08 ` [PATCH 2/5] sched: hide cfs_rq of autogroup if autogroup is disabled Yong Zhang
2011-02-20  7:08 ` [PATCH 3/5] sched, autogroup: stop going ahead " Yong Zhang
2011-02-23 12:05   ` [tip:sched/core] sched, autogroup: Stop " tip-bot for Yong Zhang
2011-02-20  7:08 ` [PATCH 4/5] sched: refactor task_group() Yong Zhang
2011-02-20  7:08 ` Yong Zhang [this message]
2011-02-20 13:09   ` [PATCH 5/5] sched, autogroup: runtime enable/disable tuning fix Mike Galbraith
2011-02-20 14:10     ` Yong Zhang
2011-02-20 17:22       ` Mike Galbraith
2011-02-21  3:13         ` Mike Galbraith
2011-02-21  9:05           ` Yong Zhang
2011-02-21 16:36         ` Peter Zijlstra
2011-02-21 21:12           ` Ingo Molnar
2011-02-22  3:13           ` Yong Zhang
2011-02-22  9:56             ` Peter Zijlstra
2011-02-22 12:10               ` [PATCH V2] sched, autogroup: always show autogroup name in sched_debug Yong Zhang
2011-02-22 14:02                 ` Mike Galbraith
2011-02-22 14:32                   ` Yong Zhang
2011-02-23 12:06                   ` [tip:sched/core] sched, autogroup: Stop claiming ownership of the root task group tip-bot for Mike Galbraith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1298185696-4403-6-git-send-email-yong.zhang0@gmail.com \
    --to=yong.zhang0@gmail.com \
    --cc=efault@gmx.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®