From: "Martin J. Bligh" Fix a minor nit with the find_busiest_group code. No functional change, but makes the code simpler and clearer. This patch does two things ... adds some more expansive comments, and removes this if clause: if (*imbalance < SCHED_LOAD_SCALE && max_load - this_load > SCHED_LOAD_SCALE) *imbalance = SCHED_LOAD_SCALE; If we remove the scaling factor, we're basically conditionally doing: if (*imbalance < 1) *imbalance = 1; Which is pointless, as the very next thing we do is to remove the scaling factor, rounding up to the nearest integer as we do: *imbalance = (*imbalance + SCHED_LOAD_SCALE - 1) >> SCHED_LOAD_SHIFT; Thus the if statement is redundant, and only makes the code harder to read ;-) --- 25-akpm/kernel/sched.c | 13 +++++++++---- 1 files changed, 9 insertions(+), 4 deletions(-) diff -puN kernel/sched.c~sched-find_busiest_group-clarification kernel/sched.c --- 25/kernel/sched.c~sched-find_busiest_group-clarification Tue Feb 3 13:16:14 2004 +++ 25-akpm/kernel/sched.c Tue Feb 3 13:16:14 2004 @@ -1442,11 +1442,16 @@ nextgroup: if (idle == NOT_IDLE && 100*max_load <= domain->imbalance_pct*this_load) goto out_balanced; - /* Take the minimum possible imbalance. */ + /* + * We're trying to get all the cpus to the average_load, so we don't + * want to push ourselves above the average load, nor do we wish to + * reduce the max loaded cpu below the average load, as either of these + * actions would just result in more rebalancing later, and ping-pong + * tasks around. Thus we look for the minimum possible imbalance. + */ *imbalance = min(max_load - avg_load, avg_load - this_load); - if (*imbalance < SCHED_LOAD_SCALE - && max_load - this_load > SCHED_LOAD_SCALE) - *imbalance = SCHED_LOAD_SCALE; + + /* Get rid of the scaling factor now, rounding *up* as we divide */ *imbalance = (*imbalance + SCHED_LOAD_SCALE - 1) >> SCHED_LOAD_SHIFT; if (*imbalance == 0) { _