lkml.org 
[lkml]   [2008]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH v1 3/5] Collect statistics required for powersave balance
Date
Update sched domain level statistics with the minimum load and
group leader who can pull more tasks. Also suggest a powersave
movement if the domain is otherwise balanced.

Signed-off-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
---

kernel/sched.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index 8c394a4..dd87061 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3219,6 +3219,103 @@ void update_sd_loads(struct sd_loads *sdl, struct group_loads *gl)

}

+#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
+void update_powersavings_group_loads(struct sd_loads *sdl,
+ struct group_loads *gl,
+ enum cpu_idle_type idle)
+{
+ int group_capacity = gl->group->__cpu_power / SCHED_LOAD_SCALE;
+
+ /*
+ * Busy processors will not participate in power savings
+ * balance.
+ */
+ if (idle == CPU_NOT_IDLE ||
+ !(sdl->sd->flags & SD_POWERSAVINGS_BALANCE))
+ return;
+
+ /*
+ * If the local group is idle or completely loaded
+ * no need to do power savings balance at this domain
+ * Same case of non-local groups as well
+ */
+ if (gl->nr_running >= group_capacity || gl->nr_running == 0)
+ return;
+
+ /*
+ * Calculate the group which has the least non-idle load.
+ * This is the group from where we need to pick up the load
+ * for saving power
+ */
+ if (!sdl->min_load_group.group)
+ sdl->min_load_group = *gl;
+ else {
+ if (gl->nr_running < sdl->min_load_group.nr_running)
+ sdl->min_load_group = *gl;
+ /* If the loads are equal, then prefer the cpu with
+ * less logical number
+ */
+ else if (gl->nr_running == sdl->min_load_group.nr_running &&
+ first_cpu(gl->group->cpumask) <
+ first_cpu(sdl->min_load_group.group->cpumask))
+ sdl->min_load_group = *gl;
+ }
+
+ /*
+ * Calculate the group which is almost near its
+ * capacity but still has some space to pick up some load
+ * from other group and save more power
+ */
+
+ if (gl->nr_running > 0 && gl->nr_running <= group_capacity - 1) {
+ if (!sdl->power_save_leader_group.group)
+ sdl->power_save_leader_group = *gl;
+ else {
+ if (gl->nr_running >
+ sdl->power_save_leader_group.nr_running)
+ sdl->power_save_leader_group = *gl;
+ else if (gl->nr_running ==
+ sdl->power_save_leader_group.nr_running &&
+ first_cpu(gl->group->cpumask) <
+ first_cpu(sdl->min_load_group.group->cpumask))
+ sdl->power_save_leader_group = *gl;
+ }
+ }
+}
+
+static struct sched_group *powersavings_balance_group(struct sd_loads *sdl,
+ struct group_loads *gl, enum cpu_idle_type idle,
+ unsigned long *imbalance)
+{
+ *imbalance = 0;
+ if (idle == CPU_NOT_IDLE || !(sdl->sd->flags & SD_POWERSAVINGS_BALANCE))
+ return NULL;
+
+ if (sdl->local.group == sdl->power_save_leader_group.group &&
+ sdl->power_save_leader_group.group !=
+ sdl->min_load_group.group) {
+ *imbalance = sdl->min_load_group.avg_load_per_task;
+ return sdl->min_load_group.group;
+ }
+
+ return NULL;
+}
+#else
+void update_powersavings_group_loads(struct sd_loads *sdl,
+ struct group_loads *gl, enum cpu_idle_type idle)
+{
+ return;
+}
+
+static struct sched_group *powersavings_balance_group(struct sd_loads *sdl,
+ struct group_loads *gl, enum cpu_idle_type idle,
+ unsigned long *imbalance)
+{
+ *imbalance = 0;
+ return NULL;
+}
+#endif
+
/*
* find_busiest_group finds and returns the busiest CPU group within the
* domain. It calculates and returns the amount of weighted load which


\
 
 \ /
  Last update: 2008-09-24 18:17    [W:0.043 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site