Commit e37b6a7b authored by Paul Turner's avatar Paul Turner Committed by Ingo Molnar

sched: Fix sign under-flows in wake_affine

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: default avatarPaul Turner <pjt@google.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: <20110122044851.734245014@google.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 6663050e
...@@ -1432,7 +1432,7 @@ static inline unsigned long effective_load(struct task_group *tg, int cpu, ...@@ -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) 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; int idx, this_cpu, prev_cpu;
unsigned long tl_per_task; unsigned long tl_per_task;
struct task_group *tg; struct task_group *tg;
...@@ -1471,8 +1471,8 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p, int sync) ...@@ -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 * Otherwise check if either cpus are near enough in load to allow this
* task to be woken on this_cpu. * task to be woken on this_cpu.
*/ */
if (this_load) { if (this_load > 0) {
unsigned long this_eff_load, prev_eff_load; s64 this_eff_load, prev_eff_load;
this_eff_load = 100; this_eff_load = 100;
this_eff_load *= power_of(prev_cpu); this_eff_load *= power_of(prev_cpu);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment