[PATCH] sched: fix load_above_capacity underflow

From: Lei Wen
Date: Tue Jun 18 2013 - 02:26:47 EST


Apparently we don't want to see sds->busiest_nr_running is small than
sds->busiest_group_capacity, while our load_above_capacity is
an "unsigned long" type.

Signed-off-by: Lei Wen <leiwen@xxxxxxxxxxx>
---
kernel/sched/fair.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index c61a614..fd90b17 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4780,12 +4780,17 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s
/*
* Don't want to pull so many tasks that a group would go idle.
*/
- load_above_capacity = (sds->busiest_nr_running -
- sds->busiest_group_capacity);
+ if (sds->busiest_has_capacity)
+ load_above_capacity = 0;
+ else {
+ load_above_capacity = (sds->busiest_nr_running -
+ sds->busiest_group_capacity);

- load_above_capacity *= (SCHED_LOAD_SCALE * SCHED_POWER_SCALE);
+ load_above_capacity *=
+ (SCHED_LOAD_SCALE * SCHED_POWER_SCALE);

- load_above_capacity /= sds->busiest->sgp->power;
+ load_above_capacity /= sds->busiest->sgp->power;
+ }
}

/*
--
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/