public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
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>
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>,
	David Collier-Brown <davecb@sun.com>,
	Tim Connors <tconnors@astro.swin.edu.au>,
	Max Krasnyansky <maxk@qualcomm.com>,
	Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>
Subject: [RFC PATCH v2 3/5] sched: collect statistics required for powersave balance
Date: Thu, 09 Oct 2008 17:39:44 +0530	[thread overview]
Message-ID: <20081009120944.27010.90362.stgit@drishya.in.ibm.com> (raw)
In-Reply-To: <20081009120705.27010.12857.stgit@drishya.in.ibm.com>

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 |   96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 96 insertions(+), 0 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index cfd83d9..c99b5bd 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3229,6 +3229,102 @@ 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 this group is idle or completely loaded, then there
+	 * is no opportunity to do power savings balance with this group
+	 */
+	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


  parent reply	other threads:[~2008-10-09 12:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-09 12:09 [RFC PATCH v2 0/5] sched: modular find_busiest_group() Vaidyanathan Srinivasan
2008-10-09 12:09 ` [RFC PATCH v2 1/5] sched: load calculation for each group in sched domain Vaidyanathan Srinivasan
2008-10-09 12:09 ` [RFC PATCH v2 2/5] sched: calculate statistics for current load balance domain Vaidyanathan Srinivasan
2008-10-09 12:09 ` Vaidyanathan Srinivasan [this message]
2008-10-09 12:09 ` [RFC PATCH v2 4/5] sched: small imbalance corrections Vaidyanathan Srinivasan
2008-10-09 12:09 ` [RFC PATCH v2 5/5] sched: split find_busiest_group() Vaidyanathan Srinivasan
2008-10-09 14:19 ` [RFC PATCH v2 0/5] sched: modular find_busiest_group() Peter Zijlstra
2008-10-10  1:36   ` Vaidyanathan Srinivasan
2008-10-14 12:09   ` Peter Zijlstra
2008-10-14 13:07     ` Vaidyanathan Srinivasan
2008-10-14 13:25       ` Peter Zijlstra
2008-10-24 10:04         ` Vaidyanathan Srinivasan

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=20081009120944.27010.90362.stgit@drishya.in.ibm.com \
    --to=svaidy@linux.vnet.ibm.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=andi@firstfloor.org \
    --cc=balbir@linux.vnet.ibm.com \
    --cc=davecb@sun.com \
    --cc=dipankar@in.ibm.com \
    --cc=ego@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxk@qualcomm.com \
    --cc=mingo@elte.hu \
    --cc=suresh.b.siddha@intel.com \
    --cc=tconnors@astro.swin.edu.au \
    --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