From: Shaohua Li <shaohua.li@intel.com>
To: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Cc: lenb@kernel.org, menage@google.com
Subject: [PATCH]cpuset: add new API to change cpuset top group's cpus
Date: Tue, 19 May 2009 15:39:42 +0800 [thread overview]
Message-ID: <20090519073942.GA10864@sli10-desk.sh.intel.com> (raw)
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 */
next reply other threads:[~2009-05-19 7:39 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-19 7:39 Shaohua Li [this message]
2009-05-19 8:40 ` [PATCH]cpuset: add new API to change cpuset top group's cpus 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
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=20090519073942.GA10864@sli10-desk.sh.intel.com \
--to=shaohua.li@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=menage@google.com \
/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