sched: Always initialize cpu-power
[firefly-linux-kernel-4.4.55.git] / kernel / sched / core.c
index 781acb91a50aa973e73ff119bfd055c8d4e7e45d..725ee7c1c8cf9a5a27f89756ac9ada7ec583bb35 100644 (file)
@@ -5604,7 +5604,12 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level,
                        break;
                }
 
-               if (!group->sgp->power) {
+               /*
+                * Even though we initialize ->power to something semi-sane,
+                * we leave power_orig unset. This allows us to detect if
+                * domain iteration is still funny without causing /0 traps.
+                */
+               if (!group->sgp->power_orig) {
                        printk(KERN_CONT "\n");
                        printk(KERN_ERR "ERROR: domain->cpu_power not "
                                        "set\n");
@@ -6075,6 +6080,12 @@ build_overlap_sched_groups(struct sched_domain *sd, int cpu)
                if (atomic_inc_return(&sg->sgp->ref) == 1)
                        build_group_mask(sd, sg);
 
+               /*
+                * Initialize sgp->power such that even if we mess up the
+                * domains and no possible iteration will get us here, we won't
+                * die on a /0 trap.
+                */
+               sg->sgp->power = SCHED_POWER_SCALE * cpumask_weight(sg_span);
 
                /*
                 * Make sure the first group of this domain contains the