Merge branch 'sched-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[firefly-linux-kernel-4.4.55.git] / kernel / sched_fair.c
index 37f22626225eb1afa2911f78e259a71853701b87..c768588e180b5ae7a83bebad45ace3ac34da0d19 100644 (file)
@@ -1076,8 +1076,6 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
        se->on_rq = 0;
        update_cfs_load(cfs_rq, 0);
        account_entity_dequeue(cfs_rq, se);
-       update_min_vruntime(cfs_rq);
-       update_cfs_shares(cfs_rq);
 
        /*
         * Normalize the entity after updating the min_vruntime because the
@@ -1086,6 +1084,9 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
         */
        if (!(flags & DEQUEUE_SLEEP))
                se->vruntime -= cfs_rq->min_vruntime;
+
+       update_min_vruntime(cfs_rq);
+       update_cfs_shares(cfs_rq);
 }
 
 /*
@@ -1584,7 +1585,7 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p,
                }
 
                /* Adjust by relative CPU power of the group */
-               avg_load = (avg_load * SCHED_LOAD_SCALE) / group->cpu_power;
+               avg_load = (avg_load * SCHED_POWER_SCALE) / group->sgp->power;
 
                if (local_group) {
                        this_load = avg_load;
@@ -1722,7 +1723,7 @@ select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flags)
                                nr_running += cpu_rq(i)->cfs.nr_running;
                        }
 
-                       capacity = DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE);
+                       capacity = DIV_ROUND_CLOSEST(power, SCHED_POWER_SCALE);
 
                        if (tmp->flags & SD_POWERSAVINGS_BALANCE)
                                nr_running /= 2;
@@ -2570,7 +2571,7 @@ static inline int check_power_save_busiest_group(struct sd_lb_stats *sds,
 
 unsigned long default_scale_freq_power(struct sched_domain *sd, int cpu)
 {
-       return SCHED_LOAD_SCALE;
+       return SCHED_POWER_SCALE;
 }
 
 unsigned long __weak arch_scale_freq_power(struct sched_domain *sd, int cpu)
@@ -2607,10 +2608,10 @@ unsigned long scale_rt_power(int cpu)
                available = total - rq->rt_avg;
        }
 
-       if (unlikely((s64)total < SCHED_LOAD_SCALE))
-               total = SCHED_LOAD_SCALE;
+       if (unlikely((s64)total < SCHED_POWER_SCALE))
+               total = SCHED_POWER_SCALE;
 
-       total >>= SCHED_LOAD_SHIFT;
+       total >>= SCHED_POWER_SHIFT;
 
        return div_u64(available, total);
 }
@@ -2618,7 +2619,7 @@ unsigned long scale_rt_power(int cpu)
 static void update_cpu_power(struct sched_domain *sd, int cpu)
 {
        unsigned long weight = sd->span_weight;
-       unsigned long power = SCHED_LOAD_SCALE;
+       unsigned long power = SCHED_POWER_SCALE;
        struct sched_group *sdg = sd->groups;
 
        if ((sd->flags & SD_SHARE_CPUPOWER) && weight > 1) {
@@ -2627,26 +2628,26 @@ static void update_cpu_power(struct sched_domain *sd, int cpu)
                else
                        power *= default_scale_smt_power(sd, cpu);
 
-               power >>= SCHED_LOAD_SHIFT;
+               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);
        else
                power *= default_scale_freq_power(sd, cpu);
 
-       power >>= SCHED_LOAD_SHIFT;
+       power >>= SCHED_POWER_SHIFT;
 
        power *= scale_rt_power(cpu);
-       power >>= SCHED_LOAD_SHIFT;
+       power >>= SCHED_POWER_SHIFT;
 
        if (!power)
                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)
@@ -2664,11 +2665,11 @@ 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;
 }
 
 /*
@@ -2682,7 +2683,7 @@ static inline int
 fix_small_capacity(struct sched_domain *sd, struct sched_group *group)
 {
        /*
-        * Only siblings can have significantly less than SCHED_LOAD_SCALE
+        * Only siblings can have significantly less than SCHED_POWER_SCALE
         */
        if (!(sd->flags & SD_SHARE_CPUPOWER))
                return 0;
@@ -2690,7 +2691,7 @@ fix_small_capacity(struct sched_domain *sd, struct sched_group *group)
        /*
         * 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;
@@ -2770,7 +2771,7 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
        }
 
        /* Adjust by relative CPU power of the group */
-       sgs->avg_load = (sgs->group_load * SCHED_LOAD_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
@@ -2787,7 +2788,8 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
        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, SCHED_LOAD_SCALE);
+       sgs->group_capacity = DIV_ROUND_CLOSEST(group->sgp->power,
+                                               SCHED_POWER_SCALE);
        if (!sgs->group_capacity)
                sgs->group_capacity = fix_small_capacity(sd, group);
        sgs->group_weight = group->group_weight;
@@ -2875,7 +2877,7 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu,
                        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,8 +2962,8 @@ static int check_asym_packing(struct sched_domain *sd,
        if (this_cpu > busiest_cpu)
                return 0;
 
-       *imbalance = DIV_ROUND_CLOSEST(sds->max_load * sds->busiest->cpu_power,
-                                      SCHED_LOAD_SCALE);
+       *imbalance = DIV_ROUND_CLOSEST(sds->max_load * sds->busiest->sgp->power,
+                                      SCHED_POWER_SCALE);
        return 1;
 }
 
@@ -2990,8 +2992,8 @@ static inline void fix_small_imbalance(struct sd_lb_stats *sds,
                        cpu_avg_load_per_task(this_cpu);
 
        scaled_busy_load_per_task = sds->busiest_load_per_task
-                                                * SCHED_LOAD_SCALE;
-       scaled_busy_load_per_task /= sds->busiest->cpu_power;
+                                        * SCHED_POWER_SCALE;
+       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)) {
@@ -3005,30 +3007,30 @@ static inline void fix_small_imbalance(struct sd_lb_stats *sds,
         * 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_LOAD_SCALE;
+       pwr_now /= SCHED_POWER_SCALE;
 
        /* Amount of load we'd subtract */
-       tmp = (sds->busiest_load_per_task * SCHED_LOAD_SCALE) /
-               sds->busiest->cpu_power;
+       tmp = (sds->busiest_load_per_task * SCHED_POWER_SCALE) /
+               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 <
-               sds->busiest_load_per_task * SCHED_LOAD_SCALE)
-               tmp = (sds->max_load * sds->busiest->cpu_power) /
-                       sds->this->cpu_power;
+       if (sds->max_load * sds->busiest->sgp->power <
+               sds->busiest_load_per_task * SCHED_POWER_SCALE)
+               tmp = (sds->max_load * sds->busiest->sgp->power) /
+                       sds->this->sgp->power;
        else
-               tmp = (sds->busiest_load_per_task * SCHED_LOAD_SCALE) /
-                       sds->this->cpu_power;
-       pwr_move += sds->this->cpu_power *
+               tmp = (sds->busiest_load_per_task * SCHED_POWER_SCALE) /
+                       sds->this->sgp->power;
+       pwr_move += sds->this->sgp->power *
                        min(sds->this_load_per_task, sds->this_load + tmp);
-       pwr_move /= SCHED_LOAD_SCALE;
+       pwr_move /= SCHED_POWER_SCALE;
 
        /* Move if we gain throughput */
        if (pwr_move > pwr_now)
@@ -3070,9 +3072,9 @@ static inline void calculate_imbalance(struct sd_lb_stats *sds, int this_cpu,
                load_above_capacity = (sds->busiest_nr_running -
                                                sds->busiest_group_capacity);
 
-               load_above_capacity *= (SCHED_LOAD_SCALE * SCHED_LOAD_SCALE);
+               load_above_capacity *= (SCHED_LOAD_SCALE * SCHED_POWER_SCALE);
 
-               load_above_capacity /= sds->busiest->cpu_power;
+               load_above_capacity /= sds->busiest->sgp->power;
        }
 
        /*
@@ -3088,9 +3090,9 @@ static inline void calculate_imbalance(struct sd_lb_stats *sds, int this_cpu,
        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)
-                       / SCHED_LOAD_SCALE;
+       *imbalance = min(max_pull * sds->busiest->sgp->power,
+               (sds->avg_load - sds->this_load) * sds->this->sgp->power)
+                       / SCHED_POWER_SCALE;
 
        /*
         * if *imbalance is less than the average load per runnable task
@@ -3159,7 +3161,7 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
        if (!sds.busiest || sds.busiest_nr_running == 0)
                goto out_balanced;
 
-       sds.avg_load = (SCHED_LOAD_SCALE * sds.total_load) / sds.total_pwr;
+       sds.avg_load = (SCHED_POWER_SCALE * sds.total_load) / sds.total_pwr;
 
        /*
         * If the busiest group is imbalanced the below checks don't
@@ -3238,7 +3240,8 @@ find_busiest_queue(struct sched_domain *sd, struct sched_group *group,
 
        for_each_cpu(i, sched_group_cpus(group)) {
                unsigned long power = power_of(i);
-               unsigned long capacity = DIV_ROUND_CLOSEST(power, SCHED_LOAD_SCALE);
+               unsigned long capacity = DIV_ROUND_CLOSEST(power,
+                                                          SCHED_POWER_SCALE);
                unsigned long wl;
 
                if (!capacity)
@@ -3263,7 +3266,7 @@ find_busiest_queue(struct sched_domain *sd, struct sched_group *group,
                 * the load can be moved away from the cpu that is potentially
                 * running at a lower capacity.
                 */
-               wl = (wl * SCHED_LOAD_SCALE) / power;
+               wl = (wl * SCHED_POWER_SCALE) / power;
 
                if (wl > max_load) {
                        max_load = wl;