sched: Add group_misfit_task load-balance type
[firefly-linux-kernel-4.4.55.git] / kernel / sched / fair.c
index 618e94ef803b0b4b0b14b576f5b8a45e08ff45bf..6c791547225c7f8c324a828124f4fb95a334e806 100644 (file)
@@ -5760,6 +5760,8 @@ again:
        if (hrtick_enabled(rq))
                hrtick_start_fair(rq, p);
 
+       rq->misfit_task = !task_fits_max(p, rq->cpu);
+
        return p;
 simple:
        cfs_rq = &rq->cfs;
@@ -5781,9 +5783,12 @@ simple:
        if (hrtick_enabled(rq))
                hrtick_start_fair(rq, p);
 
+       rq->misfit_task = !task_fits_max(p, rq->cpu);
+
        return p;
 
 idle:
+       rq->misfit_task = 0;
        /*
         * This is OK, because current is on_cpu, which avoids it being picked
         * for load-balance and preemption/IRQs are still disabled avoiding
@@ -5996,6 +6001,13 @@ static unsigned long __read_mostly max_load_balance_interval = HZ/10;
 
 enum fbq_type { regular, remote, all };
 
+enum group_type {
+       group_other = 0,
+       group_misfit_task,
+       group_imbalanced,
+       group_overloaded,
+};
+
 #define LBF_ALL_PINNED 0x01
 #define LBF_NEED_BREAK 0x02
 #define LBF_DST_PINNED  0x04
@@ -6467,12 +6479,6 @@ static unsigned long task_h_load(struct task_struct *p)
 
 /********** Helpers for find_busiest_group ************************/
 
-enum group_type {
-       group_other = 0,
-       group_imbalanced,
-       group_overloaded,
-};
-
 /*
  * sg_lb_stats - stats of a sched_group required for load_balancing
  */
@@ -6488,6 +6494,7 @@ struct sg_lb_stats {
        unsigned int group_weight;
        enum group_type group_type;
        int group_no_capacity;
+       int group_misfit_task; /* A cpu has a task too big for its capacity */
 #ifdef CONFIG_NUMA_BALANCING
        unsigned int nr_numa_running;
        unsigned int nr_preferred_running;
@@ -6804,6 +6811,9 @@ group_type group_classify(struct sched_group *group,
        if (sg_imbalanced(group))
                return group_imbalanced;
 
+       if (sgs->group_misfit_task)
+               return group_misfit_task;
+
        return group_other;
 }
 
@@ -6851,8 +6861,11 @@ static inline void update_sg_lb_stats(struct lb_env *env,
                if (idle_cpu(i))
                        sgs->idle_cpus++;
 
-               if (cpu_overutilized(i))
+               if (cpu_overutilized(i)) {
                        *overutilized = true;
+                       if (!sgs->group_misfit_task && rq->misfit_task)
+                               sgs->group_misfit_task = capacity_of(i);
+               }
        }
 
        /* Adjust by relative CPU capacity of the group */
@@ -8433,6 +8446,8 @@ static void task_tick_fair(struct rq *rq, struct task_struct *curr, int queued)
 
        if (!rq->rd->overutilized && cpu_overutilized(task_cpu(curr)))
                rq->rd->overutilized = true;
+
+       rq->misfit_task = !task_fits_max(curr, rq->cpu);
 }
 
 /*