static void idle_balance(int this_cpu, struct rq *this_rq)
  {
        struct sched_domain *sd;
-       int pulled_task = -1;
+       int pulled_task = 0;
        unsigned long next_balance = jiffies + HZ;
 -      cpumask_t tmpmask;
 +      cpumask_var_t tmpmask;
 +
 +      if (!alloc_cpumask_var(&tmpmask, GFP_ATOMIC))
 +              return;
  
        for_each_domain(this_cpu, sd) {
                unsigned long interval;
  
  /*
   * Special case: If a kmalloc of a doms_cur partition (array of
 - * cpumask_t) fails, then fallback to a single sched domain,
 - * as determined by the single cpumask_t fallback_doms.
 + * cpumask) fails, then fallback to a single sched domain,
 + * as determined by the single cpumask fallback_doms.
   */
 -static cpumask_t fallback_doms;
 +static cpumask_var_t fallback_doms;
  
- void __attribute__((weak)) arch_update_cpu_topology(void)
+ /*
+  * arch_update_cpu_topology lets virtualized architectures update the
+  * cpu core maps. It is supposed to return 1 if the topology changed
+  * or 0 if it stayed the same.
+  */
+ int __attribute__((weak)) arch_update_cpu_topology(void)
  {
+       return 0;
  }
  
  /*
  
        /* Destroy deleted domains */
        for (i = 0; i < ndoms_cur; i++) {
-               for (j = 0; j < n; j++) {
+               for (j = 0; j < n && !new_topology; j++) {
 -                      if (cpus_equal(doms_cur[i], doms_new[j])
 +                      if (cpumask_equal(&doms_cur[i], &doms_new[j])
                            && dattrs_equal(dattr_cur, i, dattr_new, j))
                                goto match1;
                }
  
        /* Build new domains */
        for (i = 0; i < ndoms_new; i++) {
-               for (j = 0; j < ndoms_cur; j++) {
+               for (j = 0; j < ndoms_cur && !new_topology; j++) {
 -                      if (cpus_equal(doms_new[i], doms_cur[j])
 +                      if (cpumask_equal(&doms_new[i], &doms_cur[j])
                            && dattrs_equal(dattr_new, i, dattr_cur, j))
                                goto match2;
                }