From: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>,
Suresh B Siddha <suresh.b.siddha@intel.com>,
Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arjan van de Ven <arjan@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>, Dipankar Sarma <dipankar@in.ibm.com>,
Balbir Singh <balbir@linux.vnet.ibm.com>,
Vatsa <vatsa@linux.vnet.ibm.com>,
Gautham R Shenoy <ego@in.ibm.com>,
Andi Kleen <andi@firstfloor.org>,
Gregory Haskins <gregory.haskins@gmail.com>,
Mike Galbraith <efault@gmx.de>,
Thomas Gleixner <tglx@linutronix.de>,
Arun Bharadwaj <arun@linux.vnet.ibm.com>,
Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Subject: [RFC PATCH v2 1/2] sched: add sched_max_capacity_pct
Date: Wed, 13 May 2009 18:41:12 +0530 [thread overview]
Message-ID: <20090513131111.21440.68651.stgit@drishya.in.ibm.com> (raw)
In-Reply-To: <20090513130541.21440.33364.stgit@drishya.in.ibm.com>
Add a new sysfs variable that can be used by user space
to pass the number of core to evacuate or force idle.
/sys/devices/system/cpu/sched_max_capacity_pct defaults to 100
This is percentage value that can be used to force idle cores.
The percentage number shall be in steps corresponding to number
of cores in the system.
On a 8 core system (dual socket quad core), each core step will
be 12.5% rounded to 12%.
Echoing 88 will use 7 cores in the system:
% No of cores
100 8
87 7
75 6
62 5
50 4
...
...
This patch will evacuate only one package (50%) in ths case.
** This is a RFC patch for discussion ***
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
---
kernel/sched.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/kernel/sched.c b/kernel/sched.c
index b902e58..f22b9f6 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3291,6 +3291,9 @@ static inline int get_sd_load_idx(struct sched_domain *sd,
#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
+
+int sched_evacuate_cores; /* No of forced-idle cores */
+
/**
* init_sd_power_savings_stats - Initialize power savings statistics for
* the given sched_domain, during load balancing.
@@ -8604,6 +8607,37 @@ static ssize_t sched_mc_power_savings_store(struct sysdev_class *class,
static SYSDEV_CLASS_ATTR(sched_mc_power_savings, 0644,
sched_mc_power_savings_show,
sched_mc_power_savings_store);
+
+static ssize_t sched_max_capacity_pct_show(struct sysdev_class *class,
+ char *page)
+{
+ int capacity;
+ /* Convert no of cores to system capacity percentage */
+ /* FIXME: Will work only for non-threaded systems */
+ capacity = 100 - sched_evacuate_cores * 100 / nr_cpu_ids;
+ return sprintf(page, "%u\n", capacity);
+}
+static ssize_t sched_max_capacity_pct_store(struct sysdev_class *class,
+ const char *buf, size_t count)
+{
+ int capacity;
+ if (!sscanf(buf, "%u", &capacity))
+ return -EINVAL;
+
+ if (capacity < 1 || capacity > 100)
+ return -EINVAL;
+
+ /* Convert user provided percentage into no-of-cores to evacuate */
+ /* FIXME: Will work only for non-threaded systems */
+ sched_evacuate_cores = (101 - capacity) * nr_cpu_ids / 100;
+ return count;
+}
+
+
+static SYSDEV_CLASS_ATTR(sched_max_capacity_pct, 0644,
+ sched_max_capacity_pct_show,
+ sched_max_capacity_pct_store);
+
#endif
#ifdef CONFIG_SCHED_SMT
@@ -8635,6 +8669,9 @@ int __init sched_create_sysfs_power_savings_entries(struct sysdev_class *cls)
if (!err && mc_capable())
err = sysfs_create_file(&cls->kset.kobj,
&attr_sched_mc_power_savings.attr);
+ if (!err)
+ err = sysfs_create_file(&cls->kset.kobj,
+ &attr_sched_max_capacity_pct.attr);
#endif
return err;
}
next prev parent reply other threads:[~2009-05-13 13:11 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-13 13:11 [RFC PATCH v2 0/2] Saving power by cpu evacuation sched_max_capacity_pct=n Vaidyanathan Srinivasan
2009-05-13 13:11 ` Vaidyanathan Srinivasan [this message]
2009-05-13 13:11 ` [RFC PATCH v2 2/2] sched: loadbalancer hacks for forced packing of tasks Vaidyanathan Srinivasan
2009-05-13 13:14 ` [RFC PATCH v2 0/2] Saving power by cpu evacuation sched_max_capacity_pct=n Peter Zijlstra
2009-05-13 13:42 ` [RFC PATCH v2 0/2] Saving power by cpu evacuationsched_max_capacity_pct=n Vaidyanathan Srinivasan
2009-05-13 13:45 ` Balbir Singh
2009-05-13 13:47 ` Peter Zijlstra
2009-05-13 14:42 ` [RFC PATCH v2 0/2] Saving power by cpuevacuationsched_max_capacity_pct=n Balbir Singh
2009-05-13 14:35 ` [RFC PATCH v2 0/2] Saving power by cpu evacuation sched_max_capacity_pct=n Andi Kleen
2009-05-13 14:36 ` Peter Zijlstra
2009-05-13 14:46 ` Andi Kleen
2009-05-13 14:50 ` Peter Zijlstra
2009-05-13 15:01 ` Andi Kleen
2009-05-13 15:02 ` Peter Zijlstra
2009-05-13 15:10 ` Andi Kleen
2009-05-14 14:58 ` Vaidyanathan Srinivasan
2009-05-14 15:06 ` Andi Kleen
2009-05-14 15:43 ` Vaidyanathan Srinivasan
2009-05-14 15:13 ` Vaidyanathan Srinivasan
2009-05-19 20:40 ` Pavel Machek
2009-05-22 9:14 ` Vaidyanathan Srinivasan
2009-05-28 20:36 ` Pavel Machek
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=20090513131111.21440.68651.stgit@drishya.in.ibm.com \
--to=svaidy@linux.vnet.ibm.com \
--cc=a.p.zijlstra@chello.nl \
--cc=andi@firstfloor.org \
--cc=arjan@infradead.org \
--cc=arun@linux.vnet.ibm.com \
--cc=balbir@linux.vnet.ibm.com \
--cc=dipankar@in.ibm.com \
--cc=efault@gmx.de \
--cc=ego@in.ibm.com \
--cc=gregory.haskins@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=vatsa@linux.vnet.ibm.com \
--cc=venkatesh.pallipadi@intel.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