diff options
Diffstat (limited to 'kernel/sched_fair.c')
-rw-r--r-- | kernel/sched_fair.c | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c index f4f6a8326dd0..00ebd7686676 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 | ||
@@ -1764,10 +1758,6 @@ static void pull_task(struct rq *src_rq, struct task_struct *p, | |||
1764 | set_task_cpu(p, this_cpu); | 1758 | set_task_cpu(p, this_cpu); |
1765 | activate_task(this_rq, p, 0); | 1759 | activate_task(this_rq, p, 0); |
1766 | check_preempt_curr(this_rq, p, 0); | 1760 | check_preempt_curr(this_rq, p, 0); |
1767 | |||
1768 | /* re-arm NEWIDLE balancing when moving tasks */ | ||
1769 | src_rq->avg_idle = this_rq->avg_idle = 2*sysctl_sched_migration_cost; | ||
1770 | this_rq->idle_stamp = 0; | ||
1771 | } | 1761 | } |
1772 | 1762 | ||
1773 | /* | 1763 | /* |
@@ -2035,13 +2025,16 @@ struct sd_lb_stats { | |||
2035 | unsigned long this_load_per_task; | 2025 | unsigned long this_load_per_task; |
2036 | unsigned long this_nr_running; | 2026 | unsigned long this_nr_running; |
2037 | unsigned long this_has_capacity; | 2027 | unsigned long this_has_capacity; |
2028 | unsigned int this_idle_cpus; | ||
2038 | 2029 | ||
2039 | /* Statistics of the busiest group */ | 2030 | /* Statistics of the busiest group */ |
2031 | unsigned int busiest_idle_cpus; | ||
2040 | unsigned long max_load; | 2032 | unsigned long max_load; |
2041 | unsigned long busiest_load_per_task; | 2033 | unsigned long busiest_load_per_task; |
2042 | unsigned long busiest_nr_running; | 2034 | unsigned long busiest_nr_running; |
2043 | unsigned long busiest_group_capacity; | 2035 | unsigned long busiest_group_capacity; |
2044 | unsigned long busiest_has_capacity; | 2036 | unsigned long busiest_has_capacity; |
2037 | unsigned int busiest_group_weight; | ||
2045 | 2038 | ||
2046 | int group_imb; /* Is there imbalance in this sd */ | 2039 | int group_imb; /* Is there imbalance in this sd */ |
2047 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) | 2040 | #if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) |
@@ -2063,6 +2056,8 @@ struct sg_lb_stats { | |||
2063 | unsigned long sum_nr_running; /* Nr tasks running in the group */ | 2056 | unsigned long sum_nr_running; /* Nr tasks running in the group */ |
2064 | unsigned long sum_weighted_load; /* Weighted load of group's tasks */ | 2057 | unsigned long sum_weighted_load; /* Weighted load of group's tasks */ |
2065 | unsigned long group_capacity; | 2058 | unsigned long group_capacity; |
2059 | unsigned long idle_cpus; | ||
2060 | unsigned long group_weight; | ||
2066 | int group_imb; /* Is there an imbalance in the group ? */ | 2061 | int group_imb; /* Is there an imbalance in the group ? */ |
2067 | int group_has_capacity; /* Is there extra capacity in the group? */ | 2062 | int group_has_capacity; /* Is there extra capacity in the group? */ |
2068 | }; | 2063 | }; |
@@ -2431,7 +2426,8 @@ static inline void update_sg_lb_stats(struct sched_domain *sd, | |||
2431 | sgs->group_load += load; | 2426 | sgs->group_load += load; |
2432 | sgs->sum_nr_running += rq->nr_running; | 2427 | sgs->sum_nr_running += rq->nr_running; |
2433 | sgs->sum_weighted_load += weighted_cpuload(i); | 2428 | sgs->sum_weighted_load += weighted_cpuload(i); |
2434 | 2429 | if (idle_cpu(i)) | |
2430 | sgs->idle_cpus++; | ||
2435 | } | 2431 | } |
2436 | 2432 | ||
2437 | /* | 2433 | /* |
@@ -2469,6 +2465,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); | 2465 | sgs->group_capacity = DIV_ROUND_CLOSEST(group->cpu_power, SCHED_LOAD_SCALE); |
2470 | if (!sgs->group_capacity) | 2466 | if (!sgs->group_capacity) |
2471 | sgs->group_capacity = fix_small_capacity(sd, group); | 2467 | sgs->group_capacity = fix_small_capacity(sd, group); |
2468 | sgs->group_weight = group->group_weight; | ||
2472 | 2469 | ||
2473 | if (sgs->group_capacity > sgs->sum_nr_running) | 2470 | if (sgs->group_capacity > sgs->sum_nr_running) |
2474 | sgs->group_has_capacity = 1; | 2471 | sgs->group_has_capacity = 1; |
@@ -2576,13 +2573,16 @@ static inline void update_sd_lb_stats(struct sched_domain *sd, int this_cpu, | |||
2576 | sds->this_nr_running = sgs.sum_nr_running; | 2573 | sds->this_nr_running = sgs.sum_nr_running; |
2577 | sds->this_load_per_task = sgs.sum_weighted_load; | 2574 | sds->this_load_per_task = sgs.sum_weighted_load; |
2578 | sds->this_has_capacity = sgs.group_has_capacity; | 2575 | sds->this_has_capacity = sgs.group_has_capacity; |
2576 | sds->this_idle_cpus = sgs.idle_cpus; | ||
2579 | } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) { | 2577 | } else if (update_sd_pick_busiest(sd, sds, sg, &sgs, this_cpu)) { |
2580 | sds->max_load = sgs.avg_load; | 2578 | sds->max_load = sgs.avg_load; |
2581 | sds->busiest = sg; | 2579 | sds->busiest = sg; |
2582 | sds->busiest_nr_running = sgs.sum_nr_running; | 2580 | sds->busiest_nr_running = sgs.sum_nr_running; |
2581 | sds->busiest_idle_cpus = sgs.idle_cpus; | ||
2583 | sds->busiest_group_capacity = sgs.group_capacity; | 2582 | sds->busiest_group_capacity = sgs.group_capacity; |
2584 | sds->busiest_load_per_task = sgs.sum_weighted_load; | 2583 | sds->busiest_load_per_task = sgs.sum_weighted_load; |
2585 | sds->busiest_has_capacity = sgs.group_has_capacity; | 2584 | sds->busiest_has_capacity = sgs.group_has_capacity; |
2585 | sds->busiest_group_weight = sgs.group_weight; | ||
2586 | sds->group_imb = sgs.group_imb; | 2586 | sds->group_imb = sgs.group_imb; |
2587 | } | 2587 | } |
2588 | 2588 | ||
@@ -2860,8 +2860,26 @@ find_busiest_group(struct sched_domain *sd, int this_cpu, | |||
2860 | if (sds.this_load >= sds.avg_load) | 2860 | if (sds.this_load >= sds.avg_load) |
2861 | goto out_balanced; | 2861 | goto out_balanced; |
2862 | 2862 | ||
2863 | if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load) | 2863 | /* |
2864 | goto out_balanced; | 2864 | * In the CPU_NEWLY_IDLE, use imbalance_pct to be conservative. |
2865 | * And to check for busy balance use !idle_cpu instead of | ||
2866 | * CPU_NOT_IDLE. This is because HT siblings will use CPU_NOT_IDLE | ||
2867 | * even when they are idle. | ||
2868 | */ | ||
2869 | if (idle == CPU_NEWLY_IDLE || !idle_cpu(this_cpu)) { | ||
2870 | if (100 * sds.max_load <= sd->imbalance_pct * sds.this_load) | ||
2871 | goto out_balanced; | ||
2872 | } else { | ||
2873 | /* | ||
2874 | * This cpu is idle. If the busiest group load doesn't | ||
2875 | * have more tasks than the number of available cpu's and | ||
2876 | * there is no imbalance between this and busiest group | ||
2877 | * wrt to idle cpu's, it is balanced. | ||
2878 | */ | ||
2879 | if ((sds.this_idle_cpus <= sds.busiest_idle_cpus + 1) && | ||
2880 | sds.busiest_nr_running <= sds.busiest_group_weight) | ||
2881 | goto out_balanced; | ||
2882 | } | ||
2865 | 2883 | ||
2866 | force_balance: | 2884 | force_balance: |
2867 | /* Looks like there is an imbalance. Compute it */ | 2885 | /* Looks like there is an imbalance. Compute it */ |
@@ -3197,8 +3215,10 @@ static void idle_balance(int this_cpu, struct rq *this_rq) | |||
3197 | interval = msecs_to_jiffies(sd->balance_interval); | 3215 | interval = msecs_to_jiffies(sd->balance_interval); |
3198 | if (time_after(next_balance, sd->last_balance + interval)) | 3216 | if (time_after(next_balance, sd->last_balance + interval)) |
3199 | next_balance = sd->last_balance + interval; | 3217 | next_balance = sd->last_balance + interval; |
3200 | if (pulled_task) | 3218 | if (pulled_task) { |
3219 | this_rq->idle_stamp = 0; | ||
3201 | break; | 3220 | break; |
3221 | } | ||
3202 | } | 3222 | } |
3203 | 3223 | ||
3204 | raw_spin_lock(&this_rq->lock); | 3224 | raw_spin_lock(&this_rq->lock); |