From patchwork Tue May 19 07:39:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shaohua Li X-Patchwork-Id: 24663 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n4J7dk8L000983 for ; Tue, 19 May 2009 07:39:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752968AbZESHjn (ORCPT ); Tue, 19 May 2009 03:39:43 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753624AbZESHjn (ORCPT ); Tue, 19 May 2009 03:39:43 -0400 Received: from mga11.intel.com ([192.55.52.93]:4159 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752968AbZESHjm (ORCPT ); Tue, 19 May 2009 03:39:42 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 19 May 2009 00:33:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.41,214,1241420400"; d="scan'208";a="691632186" Received: from sli10-conroe.sh.intel.com (HELO sli10-desk.sh.intel.com) ([10.239.13.175]) by fmsmga001.fm.intel.com with ESMTP; 19 May 2009 00:43:15 -0700 Received: from david by sli10-desk.sh.intel.com with local (Exim 4.69) (envelope-from ) id 1M6JvK-0002pv-P6; Tue, 19 May 2009 15:39:42 +0800 Date: Tue, 19 May 2009 15:39:42 +0800 From: Shaohua Li 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 Message-ID: <20090519073942.GA10864@sli10-desk.sh.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org 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 --- include/linux/cpuset.h | 5 +++++ kernel/cpuset.c | 27 ++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 */