aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sched_fair.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sched_fair.c')
-rw-r--r--kernel/sched_fair.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index f4f6a8326dd0..52ab113d8bb9 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -1654,12 +1654,6 @@ static void check_preempt_wakeup(struct rq *rq, struct task_struct *p, int wake_
1654 struct cfs_rq *cfs_rq = task_cfs_rq(curr); 1654 struct cfs_rq *cfs_rq = task_cfs_rq(curr);
1655 int scale = cfs_rq->nr_running >= sched_nr_latency; 1655 int scale = cfs_rq->nr_running >= sched_nr_latency;
1656 1656
1657 if (unlikely(rt_prio(p->prio)))
1658 goto preempt;
1659
1660 if (unlikely(p->sched_class != &fair_sched_class))
1661 return;
1662
1663 if (unlikely(se == pse)) 1657 if (unlikely(se == pse))
1664 return; 1658 return;
1665 1659
@@ -2035,13 +2029,16 @@ struct sd_lb_stats {
2035 unsigned long this_load_per_task; 2029 unsigned long this_load_per_task;
2036 unsigned long this_nr_running; 2030 unsigned long this_nr_running;
2037 unsigned long this_has_capacity; 2031 unsigned long this_has_capacity;
2032 unsigned int this_idle_cpus;
2038 2033
2039 /* Statistics of the busiest group */ 2034 /* Statistics of the busiest group */
2035 unsigned int busiest_idle_cpus;
2040 unsigned long max_load; 2036 unsigned long max_load;
2041 unsigned long busiest_load_per_task; 2037 unsigned long busiest_load_per_task;
2042 unsigned long busiest_nr_running; 2038 unsigned long busiest_nr_running;
2043 unsigned long busiest_group_capacity; 2039 unsigned long busiest_group_capacity;
2044 unsigned long busiest_has_capacity; 2040 unsigned long busiest_has_capacity;
2041 unsigned int busiest_group_weight;
2045 2042
2046 int group_imb; /* Is there imbalance in this sd */ 2043 int group_imb; /* Is there imbalance in this sd */
2047#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 2044#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
@@ -2063,6 +2060,8 @@ struct sg_lb_stats {
2063 unsigned long sum_nr_running; /* Nr tasks running in the group */ 2060 unsigned long sum_nr_running; /* Nr tasks running in the group */
2064 unsigned long sum_weighted_load; /* Weighted load of group's tasks */ 2061 unsigned long sum_weighted_load; /* Weighted load of group's tasks */
2065 unsigned long group_capacity; 2062 unsigned long group_capacity;
2063 unsigned long idle_cpus;
2064 unsigned long group_weight;
2066 int group_imb; /* Is there an imbalance in the group ? */ 2065 int group_imb; /* Is there an imbalance in the group ? */
2067 int group_has_capacity; /* Is there extra capacity in the group? */ 2066 int group_has_capacity; /* Is there extra capacity in the group? */
2068}; 2067};
@@ -2431,7 +2430,8 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
2431 sgs->group_load += load; 2430 sgs->group_load += load;
2432 sgs->sum_nr_running += rq->nr_running; 2431 sgs->sum_nr_running += rq->nr_running;
2433 sgs->sum_weighted_load += weighted_cpuload(i); 2432 sgs->sum_weighted_load += weighted_cpuload(i);
2434 2433 if (idle_cpu(i))
2434 sgs->idle_cpus++;
2435 } 2435 }
2436 2436
2437 /* 2437 /*
@@ -2469,6 +2469,7 @@ static inline void update_sg_lb_stats(struct sched_domain *sd,
2469 sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE); 2469 sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE);
2470 if (!sgs->group_capacity) 2470 if (!sgs->group_capacity)
2471 sgs->group_capacity = fix_small_capacity(sd, group); 2471 sgs->group_capacity = fix_small_capacity(sd, group);
2472 sgs->group_weight = group->group_weight;
2472 2473
2473 if (sgs->group_capacity > sgs->sum_nr_running) 2474 if (sgs->group_capacity > sgs->sum_nr_running)
2474 sgs->group_has_capacity = 1; 2475 sgs->group_has_capacity = 1;
@@ -2576,13 +2577,16 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu,
2576 sds->this_nr_running = sgs.sum_nr_running; 2577 sds->this_nr_running = sgs.sum_nr_running;
2577 sds->this_load_per_task = sgs.sum_weighted_load; 2578 sds->this_load_per_task = sgs.sum_weighted_load;
2578 sds->this_has_capacity = sgs.group_has_capacity; 2579 sds->this_has_capacity = sgs.group_has_capacity;
2580 sds->this_idle_cpus = sgs.idle_cpus;
2579 } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) { 2581 } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) {
2580 sds->max_load = sgs.avg_load; 2582 sds->max_load = sgs.avg_load;
2581 sds->busiest = sg; 2583 sds->busiest = sg;
2582 sds->busiest_nr_running = sgs.sum_nr_running; 2584 sds->busiest_nr_running = sgs.sum_nr_running;
2585 sds->busiest_idle_cpus = sgs.idle_cpus;
2583 sds->busiest_group_capacity = sgs.group_capacity; 2586 sds->busiest_group_capacity = sgs.group_capacity;
2584 sds->busiest_load_per_task = sgs.sum_weighted_load; 2587 sds->busiest_load_per_task = sgs.sum_weighted_load;
2585 sds->busiest_has_capacity = sgs.group_has_capacity; 2588 sds->busiest_has_capacity = sgs.group_has_capacity;
2589 sds->busiest_group_weight = sgs.group_weight;
2586 sds->group_imb = sgs.group_imb; 2590 sds->group_imb = sgs.group_imb;
2587 } 2591 }
2588 2592
@@ -2860,8 +2864,26 @@ find_busiest_group(struct sched_domain *sd, int this_cpu,
2860 if (sds.this_load >= sds.avg_load) 2864 if (sds.this_load >= sds.avg_load)
2861 goto out_balanced; 2865 goto out_balanced;
2862 2866
2863 if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load) 2867 /*
2864 goto out_balanced; 2868 * In the CPU_NEWLY_IDLE, use imbalance_pct to be conservative.
2869 * And to check for busy balance use !idle_cpu instead of
2870 * CPU_NOT_IDLE. This is because HT siblings will use CPU_NOT_IDLE
2871 * even when they are idle.
2872 */
2873 if (idle == CPU_NEWLY_IDLE || !idle_cpu(this_cpu)) {
2874 if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load)
2875 goto out_balanced;
2876 } else {
2877 /*
2878 * This cpu is idle. If the busiest group load doesn't
2879 * have more tasks than the number of available cpu's and
2880 * there is no imbalance between this and busiest group
2881 * wrt to idle cpu's, it is balanced.
2882 */
2883 if ((sds.this_idle_cpus <= sds.busiest_idle_cpus + 1) &&
2884 sds.busiest_nr_running <= sds.busiest_group_weight)
2885 goto out_balanced;
2886 }
2865 2887
2866force_balance: 2888force_balance:
2867 /* Looks like there is an imbalance. Compute it */ 2889 /* Looks like there is an imbalance. Compute it */