aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorGautham R Shenoy <ego@in.ibm.com>2009-03-25 05:14:27 -0400
committerIngo Molnar <mingo@elte.hu>2009-03-25 08:28:30 -0400
commitb7bb4c9bb01941fe8feb653f3410e7ed0c9bb786 (patch)
treeee6fb1ce3354c8a06c7c1b08b2c386aaebf07a33 /kernel
parentc071df18525a95b37dd5821a6dc4af83bd18675e (diff)
sched: Add comments to find_busiest_group() function
Impact: cleanup Add /** style comments around find_busiest_group(). Also add a few explanatory comments. This concludes the find_busiest_group() cleanup. The function is now down to 72 lines from the original 313 lines. Signed-off-by: Gautham R Shenoy <ego@in.ibm.com> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Suresh Siddha <suresh.b.siddha@intel.com> Cc: "Balbir Singh" <balbir@in.ibm.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: "Dhaval Giani" <dhaval@linux.vnet.ibm.com> Cc: Bharata B Rao <bharata@linux.vnet.ibm.com> Cc: "Vaidyanathan Srinivasan" <svaidy@linux.vnet.ibm.com> LKML-Reference: <20090325091427.13992.18933.stgit@sofia.in.ibm.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched.c50
1 files changed, 42 insertions, 8 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index 5f21658b0f67..9f8506d68fdc 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3676,10 +3676,30 @@ static inline void calculate_imbalance(struct sd_lb_stats *sds, int this_cpu,
3676} 3676}
3677/******* find_busiest_group() helpers end here *********************/ 3677/******* find_busiest_group() helpers end here *********************/
3678 3678
3679/* 3679/**
3680 * find_busiest_group finds and returns the busiest CPU group within the 3680 * find_busiest_group - Returns the busiest group within the sched_domain
3681 * domain. It calculates and returns the amount of weighted load which 3681 * if there is an imbalance. If there isn't an imbalance, and
3682 * should be moved to restore balance via the imbalance parameter. 3682 * the user has opted for power-savings, it returns a group whose
3683 * CPUs can be put to idle by rebalancing those tasks elsewhere, if
3684 * such a group exists.
3685 *
3686 * Also calculates the amount of weighted load which should be moved
3687 * to restore balance.
3688 *
3689 * @sd: The sched_domain whose busiest group is to be returned.
3690 * @this_cpu: The cpu for which load balancing is currently being performed.
3691 * @imbalance: Variable which stores amount of weighted load which should
3692 * be moved to restore balance/put a group to idle.
3693 * @idle: The idle status of this_cpu.
3694 * @sd_idle: The idleness of sd
3695 * @cpus: The set of CPUs under consideration for load-balancing.
3696 * @balance: Pointer to a variable indicating if this_cpu
3697 * is the appropriate cpu to perform load balancing at this_level.
3698 *
3699 * Returns: - the busiest group if imbalance exists.
3700 * - If no imbalance and user has opted for power-savings balance,
3701 * return the least loaded group whose CPUs can be
3702 * put to idle by rebalancing its tasks onto our group.
3683 */ 3703 */
3684static struct sched_group * 3704static struct sched_group *
3685find_busiest_group(struct sched_domain *sd, int this_cpu, 3705find_busiest_group(struct sched_domain *sd, int this_cpu,
@@ -3697,17 +3717,31 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
3697 update_sd_lb_stats(sd, this_cpu, idle, sd_idle, cpus, 3717 update_sd_lb_stats(sd, this_cpu, idle, sd_idle, cpus,
3698 balance, &sds); 3718 balance, &sds);
3699 3719
3720 /* Cases where imbalance does not exist from POV of this_cpu */
3721 /* 1) this_cpu is not the appropriate cpu to perform load balancing
3722 * at this level.
3723 * 2) There is no busy sibling group to pull from.
3724 * 3) This group is the busiest group.
3725 * 4) This group is more busy than the avg busieness at this
3726 * sched_domain.
3727 * 5) The imbalance is within the specified limit.
3728 * 6) Any rebalance would lead to ping-pong
3729 */
3700 if (balance && !(*balance)) 3730 if (balance && !(*balance))
3701 goto ret; 3731 goto ret;
3702 3732
3703 if (!sds.busiest || sds.this_load >= sds.max_load 3733 if (!sds.busiest || sds.busiest_nr_running == 0)
3704 || sds.busiest_nr_running == 0) 3734 goto out_balanced;
3735
3736 if (sds.this_load >= sds.max_load)
3705 goto out_balanced; 3737 goto out_balanced;
3706 3738
3707 sds.avg_load = (SCHED_LOAD_SCALE * sds.total_load) / sds.total_pwr; 3739 sds.avg_load = (SCHED_LOAD_SCALE * sds.total_load) / sds.total_pwr;
3708 3740
3709 if (sds.this_load >= sds.avg_load || 3741 if (sds.this_load >= sds.avg_load)
3710 100*sds.max_load <= sd->imbalance_pct * sds.this_load) 3742 goto out_balanced;
3743
3744 if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load)
3711 goto out_balanced; 3745 goto out_balanced;
3712 3746
3713 sds.busiest_load_per_task /= sds.busiest_nr_running; 3747 sds.busiest_load_per_task /= sds.busiest_nr_running;