[PATCH v7 6/8] sched: activate active load balancing in new idle cpus

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

Active load balancing is a process by which migration thread
is woken up on the target CPU in order to pull current
running task on another package into this newly idle
package.

This method is already in use with normal load_balance(),
this patch introduces this method to new idle cpus when
sched_mc is set to POWERSAVINGS_BALANCE_WAKEUP.

This logic provides effective consolidation of short running
daemon jobs in a almost idle system

The side effect of this patch may be ping-ponging of tasks
if the system is moderately utilised. May need to adjust the
iterations before triggering.

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

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

diff --git a/kernel/sched.c b/kernel/sched.c
index 3415fa3..f82a7a0 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3692,10 +3692,64 @@ redo:
 	}
 
 	if (!ld_moved) {
+		int active_balance;
+
 		schedstat_inc(sd, lb_failed[CPU_NEWLY_IDLE]);
 		if (!sd_idle && sd->flags & SD_SHARE_CPUPOWER &&
 		    !test_sd_parent(sd, SD_POWERSAVINGS_BALANCE))
 			return -1;
+
+		if (sched_mc_power_savings < POWERSAVINGS_BALANCE_WAKEUP)
+			return -1;
+
+		if (sd->nr_balance_failed++ < 2)
+			return -1;
+
+		/*
+		 * The only task running in a non-idle cpu can be moved to this
+		 * cpu in an attempt to completely freeup the other CPU
+		 * package. The same method used to move task in load_balance()
+		 * have been extended for load_balance_newidle() to speedup
+		 * consolidation at sched_mc=POWERSAVINGS_BALANCE_WAKEUP (2)
+		 *
+		 * The package power saving logic comes from
+		 * find_busiest_group().  If there are no imbalance, then
+		 * f_b_g() will return NULL.  However when sched_mc={1,2} then
+		 * f_b_g() will select a group from which a running task may be
+		 * pulled to this cpu in order to make the other package idle.
+		 * If there is no opportunity to make a package idle and if
+		 * there are no imbalance, then f_b_g() will return NULL and no
+		 * action will be taken in load_balance_newidle().
+		 *
+		 * Under normal task pull operation due to imbalance, there
+		 * will be more than one task in the source run queue and
+		 * move_tasks() will succeed.  ld_moved will be true and this
+		 * active balance code will not be triggered.
+		 */
+
+		/* Lock busiest in correct order while this_rq is held */
+		double_lock_balance(this_rq, busiest);
+
+		/*
+		 * don't kick the migration_thread, if the curr
+		 * task on busiest cpu can't be moved to this_cpu
+		 */
+		if (!cpu_isset(this_cpu, busiest->curr->cpus_allowed)) {
+			double_unlock_balance(this_rq, busiest);
+			all_pinned = 1;
+			return ld_moved;
+		}
+
+		if (!busiest->active_balance) {
+			busiest->active_balance = 1;
+			busiest->push_cpu = this_cpu;
+			active_balance = 1;
+		}
+
+		double_unlock_balance(this_rq, busiest);
+		if (active_balance)
+			wake_up_process(busiest->migration_thread);
+
 	} else
 		sd->nr_balance_failed = 0;
 

--
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)