[PATCH 2/2] sched: Try tp catch cpu_power being set to 0

Stefan Bader stefan.bader at canonical.com
Tue Jan 18 15:34:23 UTC 2011


This is an optional change to try catching the culprit which changes
cpu_power to 0 (should never happen) and causes divide by zero crashes
later on in the scheduler code.

BugLink: http://bugs.launchpad.net/bugs/614853

Signed-off-by: Stefan Bader <stefan.bader at canonical.com>
---
 kernel/sched.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/kernel/sched.c b/kernel/sched.c
index d4a4b14..7ef70c0 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -3713,6 +3713,7 @@ static void update_cpu_power(struct sched_domain *sd, int cpu)
 	unsigned long weight = sd->span_weight;
 	unsigned long power = SCHED_LOAD_SCALE;
 	struct sched_group *sdg = sd->groups;
+	unsigned long scale_rt;
 
 	if (sched_feat(ARCH_POWER))
 		power *= arch_scale_freq_power(sd, cpu);
@@ -3730,12 +3731,18 @@ static void update_cpu_power(struct sched_domain *sd, int cpu)
 		power >>= SCHED_LOAD_SHIFT;
 	}
 
-	power *= scale_rt_power(cpu);
+	scale_rt = scale_rt_power(cpu);
+	power *= scale_rt;
+
 	power >>= SCHED_LOAD_SHIFT;
 
 	if (!power)
 		power = 1;
 
+	if (WARN_ON((long) power <= 0))
+		printk(KERN_ERR "cpu_power = %ld; scale_rt = %ld\n",
+			power, scale_rt);
+
 	sdg->cpu_power = power;
 }
 
@@ -3759,6 +3766,9 @@ static void update_group_power(struct sched_domain *sd, int cpu)
 	} while (group != child->groups);
 
 	sdg->cpu_power = power;
+
+	if (WARN_ON((long) power <= 0))
+		printk(KERN_ERR "cpu_power = %ld\n", power);
 }
 
 /**
-- 
1.7.0.4





More information about the kernel-team mailing list