[PATCH v7 2/8] sched: Framework for sched_mc/smt_power_savings=N

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Vaidyanathan Srinivasan
Date: Thursday, December 18, 2008 - 10:56 am

From: Gautham R Shenoy <ego@in.ibm.com>

Currently the sched_mc/smt_power_savings variable is a boolean,
which either enables or disables topology based power savings.
This patch extends the behaviour of the variable from boolean to
multivalued, such that based on the value, we decide how
aggressively do we want to perform powersavings balance at
appropriate sched domain based on topology.

Variable levels of power saving tunable would benefit end user to
match the required level of power savings vs performance
trade-off depending on the system configuration and workloads.

This version makes the sched_mc_power_savings global variable to
take more values (0,1,2).  Later versions can have a single
tunable called sched_power_savings instead of
sched_{mc,smt}_power_savings.

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm.com>
---

 include/linux/sched.h |   11 +++++++++++
 kernel/sched.c        |   17 ++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 311122f..5fe906b 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -764,6 +764,17 @@ enum cpu_idle_type {
 #define SD_SERIALIZE		1024	/* Only a single load balancing instance */
 #define SD_WAKE_IDLE_FAR	2048	/* Gain latency sacrificing cache hit */
 
+enum powersavings_balance_level {
+	POWERSAVINGS_BALANCE_NONE = 0,  /* No power saving load balance */
+	POWERSAVINGS_BALANCE_BASIC,	/* Fill one thread/core/package
+					 * first for long running threads
+					 */
+	POWERSAVINGS_BALANCE_WAKEUP,	/* Also bias task wakeups to semi-idle
+					 * cpu package for power savings
+					 */
+	MAX_POWERSAVINGS_BALANCE_LEVELS
+};
+
 extern int sched_mc_power_savings, sched_smt_power_savings;
 
 static inline int sd_balance_for_mc_power(void)
diff --git a/kernel/sched.c b/kernel/sched.c
index e4bb1dd..16897ab 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -7879,14 +7879,25 @@ int arch_reinit_sched_domains(void)
 static ssize_t sched_power_savings_store(const char *buf, size_t count, int smt)
 {
 	int ret;
+	unsigned int level = 0;
 
-	if (buf[0] != '0' && buf[0] != '1')
+	if (sscanf(buf, "%u", &level) != 1)
+		return -EINVAL;
+
+	/*
+	 * level is always be positive so don't check for
+	 * level < POWERSAVINGS_BALANCE_NONE which is 0
+	 * What happens on 0 or 1 byte write,
+	 * need to check for count as well?
+	 */
+
+	if (level >= MAX_POWERSAVINGS_BALANCE_LEVELS)
 		return -EINVAL;
 
 	if (smt)
-		sched_smt_power_savings = (buf[0] == '1');
+		sched_smt_power_savings = level;
 	else
-		sched_mc_power_savings = (buf[0] == '1');
+		sched_mc_power_savings = level;
 
 	ret = arch_reinit_sched_domains();
 

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Thu Dec 18, 10:55 am)
[PATCH v7 1/8] sched: convert BALANCE_FOR_xx_POWER to inli ..., Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
[PATCH v7 2/8] sched: Framework for sched_mc/smt_power_sav ..., Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
[PATCH v7 3/8] sched: favour lower logical cpu number for ..., Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
[PATCH v7 4/8] sched: nominate preferred wakeup cpu, Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
[PATCH v7 5/8] sched: bias task wakeups to preferred semi- ..., Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
[PATCH v7 6/8] sched: activate active load balancing in ne ..., Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
[PATCH v7 7/8] sched: add SD_BALANCE_NEWIDLE at MC and CPU ..., Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
[PATCH v7 8/8] sched: idle_balance() does not call load_ba ..., Vaidyanathan Srinivasan, (Thu Dec 18, 10:56 am)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Balbir Singh, (Thu Dec 18, 11:12 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Ingo Molnar, (Thu Dec 18, 1:19 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Ingo Molnar, (Thu Dec 18, 1:31 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Fri Dec 19, 1:24 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Fri Dec 19, 1:29 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Fri Dec 19, 6:34 am)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Andrew Morton, (Fri Dec 19, 2:55 pm)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Andrew Morton, (Fri Dec 19, 3:19 pm)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Andrew Morton, (Fri Dec 19, 3:38 pm)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Vaidyanathan Srinivasan, (Fri Dec 19, 9:36 pm)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Andrew Morton, (Fri Dec 19, 9:44 pm)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Ingo Molnar, (Sat Dec 20, 12:54 am)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Vaidyanathan Srinivasan, (Sat Dec 20, 3:02 am)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Vaidyanathan Srinivasan, (Sat Dec 20, 3:36 am)
Re: [PATCH v7 4/8] sched: nominate preferred wakeup cpu, Vaidyanathan Srinivasan, (Sat Dec 20, 3:56 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, MinChan Kim, (Mon Dec 29, 4:43 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Balbir Singh, (Mon Dec 29, 7:48 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Ingo Molnar, (Mon Dec 29, 11:21 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Balbir Singh, (Mon Dec 29, 11:44 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Ingo Molnar, (Tue Dec 30, 12:20 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Tue Dec 30, 10:31 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Tue Dec 30, 11:07 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Fri Jan 2, 12:26 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Ingo Molnar, (Fri Jan 2, 3:16 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Sat Jan 3, 12:29 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Sat Jan 3, 3:16 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Sat Jan 3, 4:22 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Sun Jan 4, 8:00 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Sun Jan 4, 11:19 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Sun Jan 4, 12:52 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Sun Jan 4, 8:20 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Sun Jan 4, 9:40 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Sun Jan 4, 11:36 pm)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Mon Jan 5, 8:19 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Tue Jan 6, 2:31 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Tue Jan 6, 7:54 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Tue Jan 6, 8:07 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Tue Jan 6, 10:48 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Balbir Singh, (Tue Jan 6, 11:45 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Wed Jan 7, 1:59 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Wed Jan 7, 4:26 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Wed Jan 7, 7:36 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Wed Jan 7, 8:35 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Thu Jan 8, 1:06 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Vaidyanathan Srinivasan, (Thu Jan 8, 10:46 am)
Re: [PATCH v7 0/8] Tunable sched_mc_power_savings=n, Mike Galbraith, (Thu Jan 8, 11:00 pm)