linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]cpuset: add new API to change cpuset top group's cpus
@ 2009-05-19  7:39 Shaohua Li
  2009-05-19  8:40 ` Peter Zijlstra
  2009-05-19 19:55 ` Paul Menage
  0 siblings, 2 replies; 24+ messages in thread
From: Shaohua Li @ 2009-05-19  7:39 UTC (permalink / raw)
  To: linux-kernel, linux-acpi; +Cc: lenb, menage

ACPI 4.0 defines processor aggregator device. The device can notify OS to idle
some CPUs to save power. This isn't to hot remove cpus, but just makes cpus
idle.

This patch adds one API to change cpuset top group's cpus. If we want to
make one cpu idle, simply remove the cpu from cpuset top group's cpu list,
then all tasks will be migrate to other cpus, and other tasks will not be
migrated to this cpu again. No functional changes.

We will use this API in new ACPI processor aggregator device driver later.

Signed-off-by: Shaohua Li<shaohua.li@intel.com>
---
 include/linux/cpuset.h |    5 +++++
 kernel/cpuset.c        |   27 ++++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)

Index: linux/kernel/cpuset.c
===================================================================
--- linux.orig/kernel/cpuset.c	2009-05-12 16:27:16.000000000 +0800
+++ linux/kernel/cpuset.c	2009-05-19 10:05:36.000000000 +0800
@@ -929,14 +929,14 @@ static void update_tasks_cpumask(struct 
  * @buf: buffer of cpu numbers written to this cpuset
  */
 static int update_cpumask(struct cpuset *cs, struct cpuset *trialcs,
-			  const char *buf)
+			  const char *buf, bool top_ok)
 {
 	struct ptr_heap heap;
 	int retval;
 	int is_load_balanced;
 
 	/* top_cpuset.cpus_allowed tracks cpu_online_map; it's read-only */
-	if (cs == &top_cpuset)
+	if (cs == &top_cpuset && !top_ok)
 		return -EACCES;
 
 	/*
@@ -1496,7 +1496,7 @@ static int cpuset_write_resmask(struct c
 
 	switch (cft->private) {
 	case FILE_CPULIST:
-		retval = update_cpumask(cs, trialcs, buf);
+		retval = update_cpumask(cs, trialcs, buf, false);
 		break;
 	case FILE_MEMLIST:
 		retval = update_nodemask(cs, trialcs, buf);
@@ -1511,6 +1511,27 @@ static int cpuset_write_resmask(struct c
 	return retval;
 }
 
+int cpuset_change_top_cpumask(const char *buf)
+{
+	int retval = 0;
+	struct cpuset *cs = &top_cpuset;
+	struct cpuset *trialcs;
+
+	if (!cgroup_lock_live_group(cs->css.cgroup))
+		return -ENODEV;
+
+	trialcs = alloc_trial_cpuset(cs);
+	if (!trialcs)
+		return -ENOMEM;
+
+	retval = update_cpumask(cs, trialcs, buf, true);
+
+	free_trial_cpuset(trialcs);
+	cgroup_unlock();
+	return retval;
+}
+EXPORT_SYMBOL(cpuset_change_top_cpumask);
+
 /*
  * These ascii lists should be read in a single call, by using a user
  * buffer large enough to hold the entire map.  If read in smaller
Index: linux/include/linux/cpuset.h
===================================================================
--- linux.orig/include/linux/cpuset.h	2009-05-12 16:27:15.000000000 +0800
+++ linux/include/linux/cpuset.h	2009-05-19 10:05:36.000000000 +0800
@@ -92,6 +92,7 @@ extern void rebuild_sched_domains(void);
 
 extern void cpuset_print_task_mems_allowed(struct task_struct *p);
 
+extern int cpuset_change_top_cpumask(const char *buf);
 #else /* !CONFIG_CPUSETS */
 
 static inline int cpuset_init_early(void) { return 0; }
@@ -188,6 +189,10 @@ static inline void cpuset_print_task_mem
 {
 }
 
+static inline int cpuset_change_top_cpumask(const char *buf)
+{
+	return -ENODEV;
+}
 #endif /* !CONFIG_CPUSETS */
 
 #endif /* _LINUX_CPUSET_H */

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2009-05-28  7:46 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-19  7:39 [PATCH]cpuset: add new API to change cpuset top group's cpus Shaohua Li
2009-05-19  8:40 ` Peter Zijlstra
2009-05-19  8:48   ` Shaohua Li
2009-05-19  8:56     ` Peter Zijlstra
2009-05-19  9:06       ` Shaohua Li
2009-05-19  9:31         ` Peter Zijlstra
2009-05-19 10:38       ` Peter Zijlstra
2009-05-19 13:37         ` Vaidyanathan Srinivasan
2009-05-28  2:34           ` Len Brown
2009-05-28  7:44             ` Vaidyanathan Srinivasan
2009-05-19 19:01         ` Len Brown
2009-05-19 22:36           ` Peter Zijlstra
2009-05-20 11:58             ` Andi Kleen
2009-05-20 12:17               ` Peter Zijlstra
2009-05-20 13:13                 ` Andi Kleen
2009-05-20 13:41                   ` Peter Zijlstra
2009-05-20 14:45                     ` Andi Kleen
2009-05-20 17:36                     ` Vaidyanathan Srinivasan
2009-05-21  1:22                       ` Shaohua Li
2009-05-21  3:20                         ` Vaidyanathan Srinivasan
2009-05-20 17:21           ` Vaidyanathan Srinivasan
2009-05-19 11:27   ` Andi Kleen
2009-05-19 12:01     ` Peter Zijlstra
2009-05-19 19:55 ` Paul Menage

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).