Skip to content

Commit

Permalink
sched: fix mult overflow
Browse files Browse the repository at this point in the history
It was observed these mults can overflow.

Signed-off-by: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Srivatsa Vaddagiri <vatsa@linux.vnet.ibm.com>
Cc: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Srivatsa Vaddagiri authored and Ingo Molnar committed Jun 27, 2008
1 parent 2398f2c commit 243e0e7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,16 +1477,16 @@ load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
struct cfs_rq *busiest_cfs_rq = tg->cfs_rq[busiest_cpu];
unsigned long busiest_h_load = busiest_cfs_rq->h_load;
unsigned long busiest_weight = busiest_cfs_rq->load.weight;
long rem_load, moved_load;
u64 rem_load, moved_load;

/*
* empty group
*/
if (!busiest_cfs_rq->task_weight)
continue;

rem_load = rem_load_move * busiest_weight;
rem_load /= busiest_h_load + 1;
rem_load = (u64)rem_load_move * busiest_weight;
rem_load = div_u64(rem_load, busiest_h_load + 1);

moved_load = __load_balance_fair(this_rq, this_cpu, busiest,
rem_load, sd, idle, all_pinned, this_best_prio,
Expand All @@ -1496,7 +1496,7 @@ load_balance_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
continue;

moved_load *= busiest_h_load;
moved_load /= busiest_weight + 1;
moved_load = div_u64(moved_load, busiest_weight + 1);

rem_load_move -= moved_load;
if (rem_load_move < 0)
Expand Down

0 comments on commit 243e0e7

Please sign in to comment.