diff options
Diffstat (limited to 'kernel/sched/fair.c')
| -rw-r--r-- | kernel/sched/fair.c | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 940e6d17cf96..c099cc6eebe3 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
| @@ -2703,7 +2703,7 @@ select_task_rq_fair(struct task_struct *p, int sd_flag, int wake_flags) | |||
| 2703 | int want_sd = 1; | 2703 | int want_sd = 1; |
| 2704 | int sync = wake_flags & WF_SYNC; | 2704 | int sync = wake_flags & WF_SYNC; |
| 2705 | 2705 | ||
| 2706 | if (p->rt.nr_cpus_allowed == 1) | 2706 | if (p->nr_cpus_allowed == 1) |
| 2707 | return prev_cpu; | 2707 | return prev_cpu; |
| 2708 | 2708 | ||
| 2709 | if (sd_flag & SD_BALANCE_WAKE) { | 2709 | if (sd_flag & SD_BALANCE_WAKE) { |
| @@ -3503,15 +3503,22 @@ unsigned long __weak arch_scale_smt_power(struct sched_domain *sd, int cpu) | |||
| 3503 | unsigned long scale_rt_power(int cpu) | 3503 | unsigned long scale_rt_power(int cpu) |
| 3504 | { | 3504 | { |
| 3505 | struct rq *rq = cpu_rq(cpu); | 3505 | struct rq *rq = cpu_rq(cpu); |
| 3506 | u64 total, available; | 3506 | u64 total, available, age_stamp, avg; |
| 3507 | 3507 | ||
| 3508 | total = sched_avg_period() + (rq->clock - rq->age_stamp); | 3508 | /* |
| 3509 | * Since we're reading these variables without serialization make sure | ||
| 3510 | * we read them once before doing sanity checks on them. | ||
| 3511 | */ | ||
| 3512 | age_stamp = ACCESS_ONCE(rq->age_stamp); | ||
| 3513 | avg = ACCESS_ONCE(rq->rt_avg); | ||
| 3514 | |||
| 3515 | total = sched_avg_period() + (rq->clock - age_stamp); | ||
| 3509 | 3516 | ||
| 3510 | if (unlikely(total < rq->rt_avg)) { | 3517 | if (unlikely(total < avg)) { |
| 3511 | /* Ensures that power won't end up being negative */ | 3518 | /* Ensures that power won't end up being negative */ |
| 3512 | available = 0; | 3519 | available = 0; |
| 3513 | } else { | 3520 | } else { |
| 3514 | available = total - rq->rt_avg; | 3521 | available = total - avg; |
| 3515 | } | 3522 | } |
| 3516 | 3523 | ||
| 3517 | if (unlikely((s64)total < SCHED_POWER_SCALE)) | 3524 | if (unlikely((s64)total < SCHED_POWER_SCALE)) |
| @@ -3574,13 +3581,28 @@ void update_group_power(struct sched_domain *sd, int cpu) | |||
| 3574 | 3581 | ||
| 3575 | power = 0; | 3582 | power = 0; |
| 3576 | 3583 | ||
| 3577 | group = child->groups; | 3584 | if (child->flags & SD_OVERLAP) { |
| 3578 | do { | 3585 | /* |
| 3579 | power += group->sgp->power; | 3586 | * SD_OVERLAP domains cannot assume that child groups |
| 3580 | group = group->next; | 3587 | * span the current group. |
| 3581 | } while (group != child->groups); | 3588 | */ |
| 3582 | 3589 | ||
| 3583 | sdg->sgp->power = power; | 3590 | for_each_cpu(cpu, sched_group_cpus(sdg)) |
| 3591 | power += power_of(cpu); | ||
| 3592 | } else { | ||
| 3593 | /* | ||
| 3594 | * !SD_OVERLAP domains can assume that child groups | ||
| 3595 | * span the current group. | ||
| 3596 | */ | ||
| 3597 | |||
| 3598 | group = child->groups; | ||
| 3599 | do { | ||
| 3600 | power += group->sgp->power; | ||
| 3601 | group = group->next; | ||
| 3602 | } while (group != child->groups); | ||
| 3603 | } | ||
| 3604 | |||
| 3605 | sdg->sgp->power_orig = sdg->sgp->power = power; | ||
| 3584 | } | 3606 | } |
| 3585 | 3607 | ||
| 3586 | /* | 3608 | /* |
| @@ -3610,7 +3632,7 @@ fix_small_capacity(struct sched_domain *sd, struct sched_group *group) | |||
| 3610 | 3632 | ||
| 3611 | /** | 3633 | /** |
| 3612 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. | 3634 | * update_sg_lb_stats - Update sched_group's statistics for load balancing. |
| 3613 | * @sd: The sched_domain whose statistics are to be updated. | 3635 | * @env: The load balancing environment. |
| 3614 | * @group: sched_group whose statistics are to be updated. | 3636 | * @group: sched_group whose statistics are to be updated. |
| 3615 | * @load_idx: Load index of sched_domain of this_cpu for load calc. | 3637 | * @load_idx: Load index of sched_domain of this_cpu for load calc. |
| 3616 | * @local_group: Does group contain this_cpu. | 3638 | * @local_group: Does group contain this_cpu. |
| @@ -3630,7 +3652,7 @@ static inline void update_sg_lb_stats(struct lb_env *env, | |||
| 3630 | int i; | 3652 | int i; |
| 3631 | 3653 | ||
| 3632 | if (local_group) | 3654 | if (local_group) |
| 3633 | balance_cpu = group_first_cpu(group); | 3655 | balance_cpu = group_balance_cpu(group); |
| 3634 | 3656 | ||
| 3635 | /* Tally up the load of all CPUs in the group */ | 3657 | /* Tally up the load of all CPUs in the group */ |
| 3636 | max_cpu_load = 0; | 3658 | max_cpu_load = 0; |
| @@ -3645,7 +3667,8 @@ static inline void update_sg_lb_stats(struct lb_env *env, | |||
| 3645 | 3667 | ||
| 3646 | /* Bias balancing toward cpus of our domain */ | 3668 | /* Bias balancing toward cpus of our domain */ |
| 3647 | if (local_group) { | 3669 | if (local_group) { |
| 3648 | if (idle_cpu(i) && !first_idle_cpu) { | 3670 | if (idle_cpu(i) && !first_idle_cpu && |
| 3671 | cpumask_test_cpu(i, sched_group_mask(group))) { | ||
| 3649 | first_idle_cpu = 1; | 3672 | first_idle_cpu = 1; |
| 3650 | balance_cpu = i; | 3673 | balance_cpu = i; |
| 3651 | } | 3674 | } |
| @@ -3719,11 +3742,10 @@ static inline void update_sg_lb_stats(struct lb_env *env, | |||
| 3719 | 3742 | ||
| 3720 | /** | 3743 | /** |
| 3721 | * update_sd_pick_busiest - return 1 on busiest group | 3744 | * update_sd_pick_busiest - return 1 on busiest group |
| 3722 | * @sd: sched_domain whose statistics are to be checked | 3745 | * @env: The load balancing environment. |
| 3723 | * @sds: sched_domain statistics | 3746 | * @sds: sched_domain statistics |
| 3724 | * @sg: sched_group candidate to be checked for being the busiest | 3747 | * @sg: sched_group candidate to be checked for being the busiest |
| 3725 | * @sgs: sched_group statistics | 3748 | * @sgs: sched_group statistics |
| 3726 | * @this_cpu: the current cpu | ||
| 3727 | * | 3749 | * |
| 3728 | * Determine if @sg is a busier group than the previously selected | 3750 | * Determine if @sg is a busier group than the previously selected |
| 3729 | * busiest group. | 3751 | * busiest group. |
| @@ -3761,9 +3783,7 @@ static bool update_sd_pick_busiest(struct lb_env *env, | |||
| 3761 | 3783 | ||
| 3762 | /** | 3784 | /** |
| 3763 | * update_sd_lb_stats - Update sched_domain's statistics for load balancing. | 3785 | * update_sd_lb_stats - Update sched_domain's statistics for load balancing. |
| 3764 | * @sd: sched_domain whose statistics are to be updated. | 3786 | * @env: The load balancing environment. |
| 3765 | * @this_cpu: Cpu for which load balance is currently performed. | ||
| 3766 | * @idle: Idle status of this_cpu | ||
| 3767 | * @cpus: Set of cpus considered for load balancing. | 3787 | * @cpus: Set of cpus considered for load balancing. |
| 3768 | * @balance: Should we balance. | 3788 | * @balance: Should we balance. |
| 3769 | * @sds: variable to hold the statistics for this sched_domain. | 3789 | * @sds: variable to hold the statistics for this sched_domain. |
| @@ -3852,10 +3872,8 @@ static inline void update_sd_lb_stats(struct lb_env *env, | |||
| 3852 | * Returns 1 when packing is required and a task should be moved to | 3872 | * Returns 1 when packing is required and a task should be moved to |
| 3853 | * this CPU. The amount of the imbalance is returned in *imbalance. | 3873 | * this CPU. The amount of the imbalance is returned in *imbalance. |
| 3854 | * | 3874 | * |
| 3855 | * @sd: The sched_domain whose packing is to be checked. | 3875 | * @env: The load balancing environment. |
| 3856 | * @sds: Statistics of the sched_domain which is to be packed | 3876 | * @sds: Statistics of the sched_domain which is to be packed |
| 3857 | * @this_cpu: The cpu at whose sched_domain we're performing load-balance. | ||
| 3858 | * @imbalance: returns amount of imbalanced due to packing. | ||
| 3859 | */ | 3877 | */ |
| 3860 | static int check_asym_packing(struct lb_env *env, struct sd_lb_stats *sds) | 3878 | static int check_asym_packing(struct lb_env *env, struct sd_lb_stats *sds) |
| 3861 | { | 3879 | { |
| @@ -3881,9 +3899,8 @@ static int check_asym_packing(struct lb_env *env, struct sd_lb_stats *sds) | |||
| 3881 | * fix_small_imbalance - Calculate the minor imbalance that exists | 3899 | * fix_small_imbalance - Calculate the minor imbalance that exists |
| 3882 | * amongst the groups of a sched_domain, during | 3900 | * amongst the groups of a sched_domain, during |
| 3883 | * load balancing. | 3901 | * load balancing. |
| 3902 | * @env: The load balancing environment. | ||
| 3884 | * @sds: Statistics of the sched_domain whose imbalance is to be calculated. | 3903 | * @sds: Statistics of the sched_domain whose imbalance is to be calculated. |
| 3885 | * @this_cpu: The cpu at whose sched_domain we're performing load-balance. | ||
| 3886 | * @imbalance: Variable to store the imbalance. | ||
| 3887 | */ | 3904 | */ |
| 3888 | static inline | 3905 | static inline |
| 3889 | void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds) | 3906 | void fix_small_imbalance(struct lb_env *env, struct sd_lb_stats *sds) |
| @@ -4026,11 +4043,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s | |||
| 4026 | * Also calculates the amount of weighted load which should be moved | 4043 | * Also calculates the amount of weighted load which should be moved |
| 4027 | * to restore balance. | 4044 | * to restore balance. |
| 4028 | * | 4045 | * |
| 4029 | * @sd: The sched_domain whose busiest group is to be returned. | 4046 | * @env: The load balancing environment. |
| 4030 | * @this_cpu: The cpu for which load balancing is currently being performed. | ||
| 4031 | * @imbalance: Variable which stores amount of weighted load which should | ||
| 4032 | * be moved to restore balance/put a group to idle. | ||
| 4033 | * @idle: The idle status of this_cpu. | ||
| 4034 | * @cpus: The set of CPUs under consideration for load-balancing. | 4047 | * @cpus: The set of CPUs under consideration for load-balancing. |
| 4035 | * @balance: Pointer to a variable indicating if this_cpu | 4048 | * @balance: Pointer to a variable indicating if this_cpu |
| 4036 | * is the appropriate cpu to perform load balancing at this_level. | 4049 | * is the appropriate cpu to perform load balancing at this_level. |
