Skip to content

Commit

Permalink
sched: Fix sign under-flows in wake_affine
Browse files Browse the repository at this point in the history
While care is taken around the zero-point in effective_load to not exceed
the instantaneous rq->weight, it's still possible (e.g. using wake_idx != 0)
for (load + effective_load) to underflow.

In this case the comparing the unsigned values can result in incorrect balanced
decisions.

Signed-off-by: Paul Turner <pjt@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20110122044851.734245014@google.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Paul Turner authored and Ingo Molnar committed Jan 26, 2011
1 parent 6663050 commit e37b6a7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kernel/sched_fair.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,7 +1432,7 @@ static inline unsigned long effective_load(struct task_group *tg, int cpu,

static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
{
unsigned long this_load, load;
s64 this_load, load;
int idx, this_cpu, prev_cpu;
unsigned long tl_per_task;
struct task_group *tg;
Expand Down Expand Up @@ -1471,8 +1471,8 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync)
* Otherwise check if either cpus are near enough in load to allow this
* task to be woken on this_cpu.
*/
if (this_load) {
unsigned long this_eff_load, prev_eff_load;
if (this_load > 0) {
s64 this_eff_load, prev_eff_load;

this_eff_load = 100;
this_eff_load *= power_of(prev_cpu);
Expand Down

0 comments on commit e37b6a7

Please sign in to comment.