Merge branch 'linus' into sched/core
authorIngo Molnar <mingo@elte.hu>
Thu, 21 Jul 2011 15:59:54 +0000 (17:59 +0200)
committerIngo Molnar <mingo@elte.hu>
Thu, 21 Jul 2011 16:00:01 +0000 (18:00 +0200)
Merge reason: pick up the latest scheduler fixes.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
1  2 
include/linux/sched.h
kernel/sched.c
kernel/sched_fair.c

diff --combined include/linux/sched.h
index 9a9beef3c0fd7d27ad88ff6101a11718f4d880fb,14a6c7b545de5bf3ad51dea50d5d484cfc8bfbb5..341a4d78ddaa9836172239846e29d7cd4850bc40
@@@ -808,7 -808,7 +808,7 @@@ enum cpu_idle_type 
   * when BITS_PER_LONG <= 32 are pretty high and the returns do not justify the
   * increased costs.
   */
- #if BITS_PER_LONG > 32
+ #if 0 /* BITS_PER_LONG > 32 -- currently broken: it increases power usage under light load  */
  # define SCHED_LOAD_RESOLUTION        10
  # define scale_load(w)                ((w) << SCHED_LOAD_RESOLUTION)
  # define scale_load_down(w)   ((w) >> SCHED_LOAD_RESOLUTION)
  #define SD_SERIALIZE          0x0400  /* Only a single load balancing instance */
  #define SD_ASYM_PACKING               0x0800  /* Place busy groups earlier in the domain */
  #define SD_PREFER_SIBLING     0x1000  /* Prefer to place tasks in a sibling domain */
+ #define SD_OVERLAP            0x2000  /* sched_domains of this level overlap */
  
  enum powersavings_balance_level {
        POWERSAVINGS_BALANCE_NONE = 0,  /* No power saving load balance */
@@@ -893,16 -894,21 +894,21 @@@ static inline int sd_power_saving_flags
        return 0;
  }
  
- struct sched_group {
-       struct sched_group *next;       /* Must be a circular list */
+ struct sched_group_power {
        atomic_t ref;
        /*
         * CPU power of this group, SCHED_LOAD_SCALE being max power for a
         * single CPU.
         */
-       unsigned int cpu_power, cpu_power_orig;
+       unsigned int power, power_orig;
+ };
+ struct sched_group {
+       struct sched_group *next;       /* Must be a circular list */
+       atomic_t ref;
        unsigned int group_weight;
+       struct sched_group_power *sgp;
  
        /*
         * The CPUs this group covers.
@@@ -1254,6 -1260,9 +1260,9 @@@ struct task_struct 
  #ifdef CONFIG_PREEMPT_RCU
        int rcu_read_lock_nesting;
        char rcu_read_unlock_special;
+ #if defined(CONFIG_RCU_BOOST) && defined(CONFIG_TREE_PREEMPT_RCU)
+       int rcu_boosted;
+ #endif /* #if defined(CONFIG_RCU_BOOST) && defined(CONFIG_TREE_PREEMPT_RCU) */
        struct list_head rcu_node_entry;
  #endif /* #ifdef CONFIG_PREEMPT_RCU */
  #ifdef CONFIG_TREE_PREEMPT_RCU
@@@ -2501,7 -2510,7 +2510,7 @@@ extern int _cond_resched(void)
  
  extern int __cond_resched_lock(spinlock_t *lock);
  
 -#ifdef CONFIG_PREEMPT
 +#ifdef CONFIG_PREEMPT_COUNT
  #define PREEMPT_LOCK_OFFSET   PREEMPT_OFFSET
  #else
  #define PREEMPT_LOCK_OFFSET   0
diff --combined kernel/sched.c
index 4380a80c1e7ad2c1da2dbbfbc93e1e7db207208e,fde6ff90352583d65ff890a407200f2fb0c3073e..b0e7ad796d3b5aeeed9ce47169c51296af6e7d1c
  
  static inline int rt_policy(int policy)
  {
 -      if (unlikely(policy == SCHED_FIFO || policy == SCHED_RR))
 +      if (policy == SCHED_FIFO || policy == SCHED_RR)
                return 1;
        return 0;
  }
@@@ -292,8 -292,8 +292,8 @@@ static DEFINE_SPINLOCK(task_group_lock)
   * (The default weight is 1024 - so there's no practical
   *  limitation from this.)
   */
- #define MIN_SHARES    2
- #define MAX_SHARES    (1UL << (18 + SCHED_LOAD_RESOLUTION))
+ #define MIN_SHARES    (1UL <<  1)
+ #define MAX_SHARES    (1UL << 18)
  
  static int root_task_group_load = ROOT_TASK_GROUP_LOAD;
  #endif
@@@ -2497,7 -2497,7 +2497,7 @@@ ttwu_do_wakeup(struct rq *rq, struct ta
        if (p->sched_class->task_woken)
                p->sched_class->task_woken(rq, p);
  
 -      if (unlikely(rq->idle_stamp)) {
 +      if (rq->idle_stamp) {
                u64 delta = rq->clock - rq->idle_stamp;
                u64 max = 2*sysctl_sched_migration_cost;
  
@@@ -2544,13 -2544,9 +2544,9 @@@ static int ttwu_remote(struct task_stru
  }
  
  #ifdef CONFIG_SMP
- static void sched_ttwu_pending(void)
+ static void sched_ttwu_do_pending(struct task_struct *list)
  {
        struct rq *rq = this_rq();
-       struct task_struct *list = xchg(&rq->wake_list, NULL);
-       if (!list)
-               return;
  
        raw_spin_lock(&rq->lock);
  
        raw_spin_unlock(&rq->lock);
  }
  
+ #ifdef CONFIG_HOTPLUG_CPU
+ static void sched_ttwu_pending(void)
+ {
+       struct rq *rq = this_rq();
+       struct task_struct *list = xchg(&rq->wake_list, NULL);
+       if (!list)
+               return;
+       sched_ttwu_do_pending(list);
+ }
+ #endif /* CONFIG_HOTPLUG_CPU */
  void scheduler_ipi(void)
  {
-       sched_ttwu_pending();
+       struct rq *rq = this_rq();
+       struct task_struct *list = xchg(&rq->wake_list, NULL);
+       if (!list)
+               return;
+       /*
+        * Not all reschedule IPI handlers call irq_enter/irq_exit, since
+        * traditionally all their work was done from the interrupt return
+        * path. Now that we actually do some work, we need to make sure
+        * we do call them.
+        *
+        * Some archs already do call them, luckily irq_enter/exit nest
+        * properly.
+        *
+        * Arguably we should visit all archs and update all handlers,
+        * however a fair share of IPIs are still resched only so this would
+        * somewhat pessimize the simple resched case.
+        */
+       irq_enter();
+       sched_ttwu_do_pending(list);
+       irq_exit();
  }
  
  static void ttwu_queue_remote(struct task_struct *p, int cpu)
@@@ -2854,7 -2886,7 +2886,7 @@@ void sched_fork(struct task_struct *p
  #if defined(CONFIG_SMP)
        p->on_cpu = 0;
  #endif
 -#ifdef CONFIG_PREEMPT
 +#ifdef CONFIG_PREEMPT_COUNT
        /* Want to start with kernel preemption disabled. */
        task_thread_info(p)->preempt_count = 1;
  #endif
@@@ -4306,8 -4338,11 +4338,8 @@@ EXPORT_SYMBOL(schedule)
  
  static inline bool owner_running(struct mutex *lock, struct task_struct *owner)
  {
 -      bool ret = false;
 -
 -      rcu_read_lock();
        if (lock->owner != owner)
 -              goto fail;
 +              return false;
  
        /*
         * Ensure we emit the owner->on_cpu, dereference _after_ checking
         */
        barrier();
  
 -      ret = owner->on_cpu;
 -fail:
 -      rcu_read_unlock();
 -
 -      return ret;
 +      return owner->on_cpu;
  }
  
  /*
@@@ -4329,21 -4368,21 +4361,21 @@@ int mutex_spin_on_owner(struct mutex *l
        if (!sched_feat(OWNER_SPIN))
                return 0;
  
 +      rcu_read_lock();
        while (owner_running(lock, owner)) {
                if (need_resched())
 -                      return 0;
 +                      break;
  
                arch_mutex_cpu_relax();
        }
 +      rcu_read_unlock();
  
        /*
 -       * If the owner changed to another task there is likely
 -       * heavy contention, stop spinning.
 +       * We break out the loop above on need_resched() and when the
 +       * owner changed, which is a sign for heavy contention. Return
 +       * success only when lock->owner is NULL.
         */
 -      if (lock->owner)
 -              return 0;
 -
 -      return 1;
 +      return lock->owner == NULL;
  }
  #endif
  
@@@ -6550,7 -6589,7 +6582,7 @@@ static int sched_domain_debug_one(struc
                        break;
                }
  
-               if (!group->cpu_power) {
+               if (!group->sgp->power) {
                        printk(KERN_CONT "\n");
                        printk(KERN_ERR "ERROR: domain->cpu_power not "
                                        "set\n");
                cpulist_scnprintf(str, sizeof(str), sched_group_cpus(group));
  
                printk(KERN_CONT " %s", str);
-               if (group->cpu_power != SCHED_POWER_SCALE) {
+               if (group->sgp->power != SCHED_POWER_SCALE) {
                        printk(KERN_CONT " (cpu_power = %d)",
-                               group->cpu_power);
+                               group->sgp->power);
                }
  
                group = group->next;
@@@ -6767,11 -6806,39 +6799,39 @@@ static struct root_domain *alloc_rootdo
        return rd;
  }
  
+ static void free_sched_groups(struct sched_group *sg, int free_sgp)
+ {
+       struct sched_group *tmp, *first;
+       if (!sg)
+               return;
+       first = sg;
+       do {
+               tmp = sg->next;
+               if (free_sgp && atomic_dec_and_test(&sg->sgp->ref))
+                       kfree(sg->sgp);
+               kfree(sg);
+               sg = tmp;
+       } while (sg != first);
+ }
  static void free_sched_domain(struct rcu_head *rcu)
  {
        struct sched_domain *sd = container_of(rcu, struct sched_domain, rcu);
-       if (atomic_dec_and_test(&sd->groups->ref))
+       /*
+        * If its an overlapping domain it has private groups, iterate and
+        * nuke them all.
+        */
+       if (sd->flags & SD_OVERLAP) {
+               free_sched_groups(sd->groups, 1);
+       } else if (atomic_dec_and_test(&sd->groups->ref)) {
+               kfree(sd->groups->sgp);
                kfree(sd->groups);
+       }
        kfree(sd);
  }
  
@@@ -6938,6 -7005,7 +6998,7 @@@ int sched_smt_power_savings = 0, sched_
  struct sd_data {
        struct sched_domain **__percpu sd;
        struct sched_group **__percpu sg;
+       struct sched_group_power **__percpu sgp;
  };
  
  struct s_data {
@@@ -6957,15 -7025,73 +7018,73 @@@ struct sched_domain_topology_level
  typedef struct sched_domain *(*sched_domain_init_f)(struct sched_domain_topology_level *tl, int cpu);
  typedef const struct cpumask *(*sched_domain_mask_f)(int cpu);
  
+ #define SDTL_OVERLAP  0x01
  struct sched_domain_topology_level {
        sched_domain_init_f init;
        sched_domain_mask_f mask;
+       int                 flags;
        struct sd_data      data;
  };
  
- /*
-  * Assumes the sched_domain tree is fully constructed
-  */
+ static int
+ build_overlap_sched_groups(struct sched_domain *sd, int cpu)
+ {
+       struct sched_group *first = NULL, *last = NULL, *groups = NULL, *sg;
+       const struct cpumask *span = sched_domain_span(sd);
+       struct cpumask *covered = sched_domains_tmpmask;
+       struct sd_data *sdd = sd->private;
+       struct sched_domain *child;
+       int i;
+       cpumask_clear(covered);
+       for_each_cpu(i, span) {
+               struct cpumask *sg_span;
+               if (cpumask_test_cpu(i, covered))
+                       continue;
+               sg = kzalloc_node(sizeof(struct sched_group) + cpumask_size(),
+                               GFP_KERNEL, cpu_to_node(i));
+               if (!sg)
+                       goto fail;
+               sg_span = sched_group_cpus(sg);
+               child = *per_cpu_ptr(sdd->sd, i);
+               if (child->child) {
+                       child = child->child;
+                       cpumask_copy(sg_span, sched_domain_span(child));
+               } else
+                       cpumask_set_cpu(i, sg_span);
+               cpumask_or(covered, covered, sg_span);
+               sg->sgp = *per_cpu_ptr(sdd->sgp, cpumask_first(sg_span));
+               atomic_inc(&sg->sgp->ref);
+               if (cpumask_test_cpu(cpu, sg_span))
+                       groups = sg;
+               if (!first)
+                       first = sg;
+               if (last)
+                       last->next = sg;
+               last = sg;
+               last->next = first;
+       }
+       sd->groups = groups;
+       return 0;
+ fail:
+       free_sched_groups(first, 0);
+       return -ENOMEM;
+ }
  static int get_group(int cpu, struct sd_data *sdd, struct sched_group **sg)
  {
        struct sched_domain *sd = *per_cpu_ptr(sdd->sd, cpu);
        if (child)
                cpu = cpumask_first(sched_domain_span(child));
  
-       if (sg)
+       if (sg) {
                *sg = *per_cpu_ptr(sdd->sg, cpu);
+               (*sg)->sgp = *per_cpu_ptr(sdd->sgp, cpu);
+               atomic_set(&(*sg)->sgp->ref, 1); /* for claim_allocations */
+       }
  
        return cpu;
  }
  
  /*
-  * build_sched_groups takes the cpumask we wish to span, and a pointer
-  * to a function which identifies what group(along with sched group) a CPU
-  * belongs to. The return value of group_fn must be a >= 0 and < nr_cpu_ids
-  * (due to the fact that we keep track of groups covered with a struct cpumask).
-  *
   * build_sched_groups will build a circular linked list of the groups
   * covered by the given span, and will set each group's ->cpumask correctly,
   * and ->cpu_power to 0.
+  *
+  * Assumes the sched_domain tree is fully constructed
   */
- static void
- build_sched_groups(struct sched_domain *sd)
+ static int
+ build_sched_groups(struct sched_domain *sd, int cpu)
  {
        struct sched_group *first = NULL, *last = NULL;
        struct sd_data *sdd = sd->private;
        struct cpumask *covered;
        int i;
  
+       get_group(cpu, sdd, &sd->groups);
+       atomic_inc(&sd->groups->ref);
+       if (cpu != cpumask_first(sched_domain_span(sd)))
+               return 0;
        lockdep_assert_held(&sched_domains_mutex);
        covered = sched_domains_tmpmask;
  
                        continue;
  
                cpumask_clear(sched_group_cpus(sg));
-               sg->cpu_power = 0;
+               sg->sgp->power = 0;
  
                for_each_cpu(j, span) {
                        if (get_group(j, sdd, NULL) != group)
                last = sg;
        }
        last->next = first;
+       return 0;
  }
  
  /*
   */
  static void init_sched_groups_power(int cpu, struct sched_domain *sd)
  {
-       WARN_ON(!sd || !sd->groups);
+       struct sched_group *sg = sd->groups;
  
-       if (cpu != group_first_cpu(sd->groups))
-               return;
+       WARN_ON(!sd || !sg);
+       do {
+               sg->group_weight = cpumask_weight(sched_group_cpus(sg));
+               sg = sg->next;
+       } while (sg != sd->groups);
  
-       sd->groups->group_weight = cpumask_weight(sched_group_cpus(sd->groups));
+       if (cpu != group_first_cpu(sg))
+               return;
  
        update_group_power(sd, cpu);
  }
@@@ -7170,15 -7309,15 +7302,15 @@@ static enum s_alloc __visit_domain_allo
  static void claim_allocations(int cpu, struct sched_domain *sd)
  {
        struct sd_data *sdd = sd->private;
-       struct sched_group *sg = sd->groups;
  
        WARN_ON_ONCE(*per_cpu_ptr(sdd->sd, cpu) != sd);
        *per_cpu_ptr(sdd->sd, cpu) = NULL;
  
-       if (cpu == cpumask_first(sched_group_cpus(sg))) {
-               WARN_ON_ONCE(*per_cpu_ptr(sdd->sg, cpu) != sg);
+       if (atomic_read(&(*per_cpu_ptr(sdd->sg, cpu))->ref))
                *per_cpu_ptr(sdd->sg, cpu) = NULL;
-       }
+       if (atomic_read(&(*per_cpu_ptr(sdd->sgp, cpu))->ref))
+               *per_cpu_ptr(sdd->sgp, cpu) = NULL;
  }
  
  #ifdef CONFIG_SCHED_SMT
@@@ -7203,7 -7342,7 +7335,7 @@@ static struct sched_domain_topology_lev
  #endif
        { sd_init_CPU, cpu_cpu_mask, },
  #ifdef CONFIG_NUMA
-       { sd_init_NODE, cpu_node_mask, },
+       { sd_init_NODE, cpu_node_mask, SDTL_OVERLAP, },
        { sd_init_ALLNODES, cpu_allnodes_mask, },
  #endif
        { NULL, },
@@@ -7227,9 -7366,14 +7359,14 @@@ static int __sdt_alloc(const struct cpu
                if (!sdd->sg)
                        return -ENOMEM;
  
+               sdd->sgp = alloc_percpu(struct sched_group_power *);
+               if (!sdd->sgp)
+                       return -ENOMEM;
                for_each_cpu(j, cpu_map) {
                        struct sched_domain *sd;
                        struct sched_group *sg;
+                       struct sched_group_power *sgp;
  
                        sd = kzalloc_node(sizeof(struct sched_domain) + cpumask_size(),
                                        GFP_KERNEL, cpu_to_node(j));
                                return -ENOMEM;
  
                        *per_cpu_ptr(sdd->sg, j) = sg;
+                       sgp = kzalloc_node(sizeof(struct sched_group_power),
+                                       GFP_KERNEL, cpu_to_node(j));
+                       if (!sgp)
+                               return -ENOMEM;
+                       *per_cpu_ptr(sdd->sgp, j) = sgp;
                }
        }
  
@@@ -7259,11 -7410,15 +7403,15 @@@ static void __sdt_free(const struct cpu
                struct sd_data *sdd = &tl->data;
  
                for_each_cpu(j, cpu_map) {
-                       kfree(*per_cpu_ptr(sdd->sd, j));
+                       struct sched_domain *sd = *per_cpu_ptr(sdd->sd, j);
+                       if (sd && (sd->flags & SD_OVERLAP))
+                               free_sched_groups(sd->groups, 0);
                        kfree(*per_cpu_ptr(sdd->sg, j));
+                       kfree(*per_cpu_ptr(sdd->sgp, j));
                }
                free_percpu(sdd->sd);
                free_percpu(sdd->sg);
+               free_percpu(sdd->sgp);
        }
  }
  
@@@ -7309,8 -7464,13 +7457,13 @@@ static int build_sched_domains(const st
                struct sched_domain_topology_level *tl;
  
                sd = NULL;
-               for (tl = sched_domain_topology; tl->init; tl++)
+               for (tl = sched_domain_topology; tl->init; tl++) {
                        sd = build_sched_domain(tl, &d, cpu_map, attr, sd, i);
+                       if (tl->flags & SDTL_OVERLAP || sched_feat(FORCE_SD_OVERLAP))
+                               sd->flags |= SD_OVERLAP;
+                       if (cpumask_equal(cpu_map, sched_domain_span(sd)))
+                               break;
+               }
  
                while (sd->child)
                        sd = sd->child;
        for_each_cpu(i, cpu_map) {
                for (sd = *per_cpu_ptr(d.sd, i); sd; sd = sd->parent) {
                        sd->span_weight = cpumask_weight(sched_domain_span(sd));
-                       get_group(i, sd->private, &sd->groups);
-                       atomic_inc(&sd->groups->ref);
-                       if (i != cpumask_first(sched_domain_span(sd)))
-                               continue;
-                       build_sched_groups(sd);
+                       if (sd->flags & SD_OVERLAP) {
+                               if (build_overlap_sched_groups(sd, i))
+                                       goto error;
+                       } else {
+                               if (build_sched_groups(sd, i))
+                                       goto error;
+                       }
                }
        }
  
@@@ -7750,6 -7910,9 +7903,9 @@@ static void init_cfs_rq(struct cfs_rq *
  #endif
  #endif
        cfs_rq->min_vruntime = (u64)(-(1LL << 20));
+ #ifndef CONFIG_64BIT
+       cfs_rq->min_vruntime_copy = cfs_rq->min_vruntime;
+ #endif
  }
  
  static void init_rt_rq(struct rt_rq *rt_rq, struct rq *rq)
@@@ -8022,7 -8185,7 +8178,7 @@@ void __init sched_init(void
        scheduler_running = 1;
  }
  
 -#ifdef CONFIG_DEBUG_SPINLOCK_SLEEP
 +#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
  static inline int preempt_count_equals(int preempt_offset)
  {
        int nested = (preempt_count() & ~PREEMPT_ACTIVE) + rcu_preempt_depth();
  
  void __might_sleep(const char *file, int line, int preempt_offset)
  {
 -#ifdef in_atomic
        static unsigned long prev_jiffy;        /* ratelimiting */
  
        if ((preempt_count_equals(preempt_offset) && !irqs_disabled()) ||
        if (irqs_disabled())
                print_irqtrace_events(current);
        dump_stack();
 -#endif
  }
  EXPORT_SYMBOL(__might_sleep);
  #endif
@@@ -8441,10 -8606,7 +8597,7 @@@ int sched_group_set_shares(struct task_
        if (!tg->se[0])
                return -EINVAL;
  
-       if (shares < MIN_SHARES)
-               shares = MIN_SHARES;
-       else if (shares > MAX_SHARES)
-               shares = MAX_SHARES;
+       shares = clamp(shares, scale_load(MIN_SHARES), scale_load(MAX_SHARES));
  
        mutex_lock(&shares_mutex);
        if (tg->shares == shares)
diff --combined kernel/sched_fair.c
index eb98f77b38ef72d0072de05baa7818dbc4748770,c768588e180b5ae7a83bebad45ace3ac34da0d19..e7d67a9e259a7eda9c7050b63f006f90aca943d8
@@@ -1481,6 -1481,7 +1481,6 @@@ static int wake_affine(struct sched_dom
         * effect of the currently running task from the load
         * of the current CPU:
         */
 -      rcu_read_lock();
        if (sync) {
                tg = task_group(current);
                weight = current->se.load.weight;
                balanced = this_eff_load <= prev_eff_load;
        } else
                balanced = true;
 -      rcu_read_unlock();
  
        /*
         * If the currently running task will sleep within
@@@ -1583,7 -1585,7 +1583,7 @@@ find_idlest_group(struct sched_domain *
                }
  
                /* Adjust by relative CPU power of the group */
-               avg_load = (avg_load * SCHED_POWER_SCALE) / group->cpu_power;
+               avg_load = (avg_load * SCHED_POWER_SCALE) / group->sgp->power;
  
                if (local_group) {
                        this_load = avg_load;
@@@ -2629,7 -2631,7 +2629,7 @@@ static void update_cpu_power(struct sch
                power >>= SCHED_POWER_SHIFT;
        }
  
-       sdg->cpu_power_orig = power;
+       sdg->sgp->power_orig = power;
  
        if (sched_feat(ARCH_POWER))
                power *= arch_scale_freq_power(sd, cpu);
                power = 1;
  
        cpu_rq(cpu)->cpu_power = power;
-       sdg->cpu_power = power;
+       sdg->sgp->power = power;
  }
  
  static void update_group_power(struct sched_domain *sd, int cpu)
  
        group = child->groups;
        do {
-               power += group->cpu_power;
+               power += group->sgp->power;
                group = group->next;
        } while (group != child->groups);
  
-       sdg->cpu_power = power;
+       sdg->sgp->power = power;
  }
  
  /*
@@@ -2689,7 -2691,7 +2689,7 @@@ fix_small_capacity(struct sched_domain 
        /*
         * If ~90% of the cpu_power is still there, we're good.
         */
-       if (group->cpu_power * 32 > group->cpu_power_orig * 29)
+       if (group->sgp->power * 32 > group->sgp->power_orig * 29)
                return 1;
  
        return 0;
@@@ -2769,7 -2771,7 +2769,7 @@@ static inline void update_sg_lb_stats(s
        }
  
        /* Adjust by relative CPU power of the group */
-       sgs->avg_load = (sgs->group_load*SCHED_POWER_SCALE) / group->cpu_power;
+       sgs->avg_load = (sgs->group_load*SCHED_POWER_SCALE) / group->sgp->power;
  
        /*
         * Consider the group unbalanced when the imbalance is larger
        if ((max_cpu_load - min_cpu_load) >= avg_load_per_task && max_nr_running > 1)
                sgs->group_imb = 1;
  
-       sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power,
+       sgs->group_capacity = DIV_ROUND_CLOSEST(group->sgp->power,
                                                SCHED_POWER_SCALE);
        if (!sgs->group_capacity)
                sgs->group_capacity = fix_small_capacity(sd, group);
@@@ -2875,7 -2877,7 +2875,7 @@@ static inline void update_sd_lb_stats(s
                        return;
  
                sds->total_load += sgs.group_load;
-               sds->total_pwr += sg->cpu_power;
+               sds->total_pwr += sg->sgp->power;
  
                /*
                 * In case the child domain prefers tasks go to siblings
@@@ -2960,7 -2962,7 +2960,7 @@@ static int check_asym_packing(struct sc
        if (this_cpu > busiest_cpu)
                return 0;
  
-       *imbalance = DIV_ROUND_CLOSEST(sds->max_load * sds->busiest->cpu_power,
+       *imbalance = DIV_ROUND_CLOSEST(sds->max_load * sds->busiest->sgp->power,
                                       SCHED_POWER_SCALE);
        return 1;
  }
@@@ -2991,7 -2993,7 +2991,7 @@@ static inline void fix_small_imbalance(
  
        scaled_busy_load_per_task = sds->busiest_load_per_task
                                         * SCHED_POWER_SCALE;
-       scaled_busy_load_per_task /= sds->busiest->cpu_power;
+       scaled_busy_load_per_task /= sds->busiest->sgp->power;
  
        if (sds->max_load - sds->this_load + scaled_busy_load_per_task >=
                        (scaled_busy_load_per_task * imbn)) {
         * moving them.
         */
  
-       pwr_now += sds->busiest->cpu_power *
+       pwr_now += sds->busiest->sgp->power *
                        min(sds->busiest_load_per_task, sds->max_load);
-       pwr_now += sds->this->cpu_power *
+       pwr_now += sds->this->sgp->power *
                        min(sds->this_load_per_task, sds->this_load);
        pwr_now /= SCHED_POWER_SCALE;
  
        /* Amount of load we'd subtract */
        tmp = (sds->busiest_load_per_task * SCHED_POWER_SCALE) /
-               sds->busiest->cpu_power;
+               sds->busiest->sgp->power;
        if (sds->max_load > tmp)
-               pwr_move += sds->busiest->cpu_power *
+               pwr_move += sds->busiest->sgp->power *
                        min(sds->busiest_load_per_task, sds->max_load - tmp);
  
        /* Amount of load we'd add */
-       if (sds->max_load * sds->busiest->cpu_power <
+       if (sds->max_load * sds->busiest->sgp->power <
                sds->busiest_load_per_task * SCHED_POWER_SCALE)
-               tmp = (sds->max_load * sds->busiest->cpu_power) /
-                       sds->this->cpu_power;
+               tmp = (sds->max_load * sds->busiest->sgp->power) /
+                       sds->this->sgp->power;
        else
                tmp = (sds->busiest_load_per_task * SCHED_POWER_SCALE) /
-                       sds->this->cpu_power;
-       pwr_move += sds->this->cpu_power *
+                       sds->this->sgp->power;
+       pwr_move += sds->this->sgp->power *
                        min(sds->this_load_per_task, sds->this_load + tmp);
        pwr_move /= SCHED_POWER_SCALE;
  
@@@ -3072,7 -3074,7 +3072,7 @@@ static inline void calculate_imbalance(
  
                load_above_capacity *= (SCHED_LOAD_SCALE * SCHED_POWER_SCALE);
  
-               load_above_capacity /= sds->busiest->cpu_power;
+               load_above_capacity /= sds->busiest->sgp->power;
        }
  
        /*
        max_pull = min(sds->max_load - sds->avg_load, load_above_capacity);
  
        /* How much load to actually move to equalise the imbalance */
-       *imbalance = min(max_pull * sds->busiest->cpu_power,
-               (sds->avg_load - sds->this_load) * sds->this->cpu_power)
+       *imbalance = min(max_pull * sds->busiest->sgp->power,
+               (sds->avg_load - sds->this_load) * sds->this->sgp->power)
                        / SCHED_POWER_SCALE;
  
        /*