.. | .. |
---|
3938 | 3938 | } |
---|
3939 | 3939 | |
---|
3940 | 3940 | #ifdef CONFIG_UCLAMP_TASK |
---|
3941 | | -static inline unsigned long uclamp_task_util(struct task_struct *p) |
---|
| 3941 | +static inline unsigned long uclamp_task_util(struct task_struct *p, |
---|
| 3942 | + unsigned long uclamp_min, |
---|
| 3943 | + unsigned long uclamp_max) |
---|
3942 | 3944 | { |
---|
3943 | | - return clamp(task_util_est(p), |
---|
3944 | | - uclamp_eff_value(p, UCLAMP_MIN), |
---|
3945 | | - uclamp_eff_value(p, UCLAMP_MAX)); |
---|
| 3945 | + return clamp(task_util_est(p), uclamp_min, uclamp_max); |
---|
3946 | 3946 | } |
---|
3947 | 3947 | #else |
---|
3948 | | -static inline unsigned long uclamp_task_util(struct task_struct *p) |
---|
| 3948 | +static inline unsigned long uclamp_task_util(struct task_struct *p, |
---|
| 3949 | + unsigned long uclamp_min, |
---|
| 3950 | + unsigned long uclamp_max) |
---|
3949 | 3951 | { |
---|
3950 | 3952 | return task_util_est(p); |
---|
3951 | 3953 | } |
---|
.. | .. |
---|
4089 | 4091 | trace_sched_util_est_se_tp(&p->se); |
---|
4090 | 4092 | } |
---|
4091 | 4093 | |
---|
4092 | | -static inline int task_fits_capacity(struct task_struct *p, long capacity) |
---|
| 4094 | +static inline int util_fits_cpu(unsigned long util, |
---|
| 4095 | + unsigned long uclamp_min, |
---|
| 4096 | + unsigned long uclamp_max, |
---|
| 4097 | + int cpu) |
---|
4093 | 4098 | { |
---|
4094 | | - return fits_capacity(uclamp_task_util(p), capacity); |
---|
| 4099 | + unsigned long capacity_orig, capacity_orig_thermal; |
---|
| 4100 | + unsigned long capacity = capacity_of(cpu); |
---|
| 4101 | + bool fits, uclamp_max_fits; |
---|
| 4102 | + |
---|
| 4103 | + /* |
---|
| 4104 | + * Check if the real util fits without any uclamp boost/cap applied. |
---|
| 4105 | + */ |
---|
| 4106 | + fits = fits_capacity(util, capacity); |
---|
| 4107 | + |
---|
| 4108 | + if (!uclamp_is_used()) |
---|
| 4109 | + return fits; |
---|
| 4110 | + |
---|
| 4111 | + /* |
---|
| 4112 | + * We must use capacity_orig_of() for comparing against uclamp_min and |
---|
| 4113 | + * uclamp_max. We only care about capacity pressure (by using |
---|
| 4114 | + * capacity_of()) for comparing against the real util. |
---|
| 4115 | + * |
---|
| 4116 | + * If a task is boosted to 1024 for example, we don't want a tiny |
---|
| 4117 | + * pressure to skew the check whether it fits a CPU or not. |
---|
| 4118 | + * |
---|
| 4119 | + * Similarly if a task is capped to capacity_orig_of(little_cpu), it |
---|
| 4120 | + * should fit a little cpu even if there's some pressure. |
---|
| 4121 | + * |
---|
| 4122 | + * Only exception is for thermal pressure since it has a direct impact |
---|
| 4123 | + * on available OPP of the system. |
---|
| 4124 | + * |
---|
| 4125 | + * We honour it for uclamp_min only as a drop in performance level |
---|
| 4126 | + * could result in not getting the requested minimum performance level. |
---|
| 4127 | + * |
---|
| 4128 | + * For uclamp_max, we can tolerate a drop in performance level as the |
---|
| 4129 | + * goal is to cap the task. So it's okay if it's getting less. |
---|
| 4130 | + * |
---|
| 4131 | + * In case of capacity inversion, which is not handled yet, we should |
---|
| 4132 | + * honour the inverted capacity for both uclamp_min and uclamp_max all |
---|
| 4133 | + * the time. |
---|
| 4134 | + */ |
---|
| 4135 | + capacity_orig = capacity_orig_of(cpu); |
---|
| 4136 | + capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure(cpu); |
---|
| 4137 | + |
---|
| 4138 | + /* |
---|
| 4139 | + * We want to force a task to fit a cpu as implied by uclamp_max. |
---|
| 4140 | + * But we do have some corner cases to cater for.. |
---|
| 4141 | + * |
---|
| 4142 | + * |
---|
| 4143 | + * C=z |
---|
| 4144 | + * | ___ |
---|
| 4145 | + * | C=y | | |
---|
| 4146 | + * |_ _ _ _ _ _ _ _ _ ___ _ _ _ | _ | _ _ _ _ _ uclamp_max |
---|
| 4147 | + * | C=x | | | | |
---|
| 4148 | + * | ___ | | | | |
---|
| 4149 | + * | | | | | | | (util somewhere in this region) |
---|
| 4150 | + * | | | | | | | |
---|
| 4151 | + * | | | | | | | |
---|
| 4152 | + * +---------------------------------------- |
---|
| 4153 | + * cpu0 cpu1 cpu2 |
---|
| 4154 | + * |
---|
| 4155 | + * In the above example if a task is capped to a specific performance |
---|
| 4156 | + * point, y, then when: |
---|
| 4157 | + * |
---|
| 4158 | + * * util = 80% of x then it does not fit on cpu0 and should migrate |
---|
| 4159 | + * to cpu1 |
---|
| 4160 | + * * util = 80% of y then it is forced to fit on cpu1 to honour |
---|
| 4161 | + * uclamp_max request. |
---|
| 4162 | + * |
---|
| 4163 | + * which is what we're enforcing here. A task always fits if |
---|
| 4164 | + * uclamp_max <= capacity_orig. But when uclamp_max > capacity_orig, |
---|
| 4165 | + * the normal upmigration rules should withhold still. |
---|
| 4166 | + * |
---|
| 4167 | + * Only exception is when we are on max capacity, then we need to be |
---|
| 4168 | + * careful not to block overutilized state. This is so because: |
---|
| 4169 | + * |
---|
| 4170 | + * 1. There's no concept of capping at max_capacity! We can't go |
---|
| 4171 | + * beyond this performance level anyway. |
---|
| 4172 | + * 2. The system is being saturated when we're operating near |
---|
| 4173 | + * max capacity, it doesn't make sense to block overutilized. |
---|
| 4174 | + */ |
---|
| 4175 | + uclamp_max_fits = (capacity_orig == SCHED_CAPACITY_SCALE) && (uclamp_max == SCHED_CAPACITY_SCALE); |
---|
| 4176 | + uclamp_max_fits = !uclamp_max_fits && (uclamp_max <= capacity_orig); |
---|
| 4177 | + fits = fits || uclamp_max_fits; |
---|
| 4178 | + |
---|
| 4179 | + /* |
---|
| 4180 | + * |
---|
| 4181 | + * C=z |
---|
| 4182 | + * | ___ (region a, capped, util >= uclamp_max) |
---|
| 4183 | + * | C=y | | |
---|
| 4184 | + * |_ _ _ _ _ _ _ _ _ ___ _ _ _ | _ | _ _ _ _ _ uclamp_max |
---|
| 4185 | + * | C=x | | | | |
---|
| 4186 | + * | ___ | | | | (region b, uclamp_min <= util <= uclamp_max) |
---|
| 4187 | + * |_ _ _|_ _|_ _ _ _| _ | _ _ _| _ | _ _ _ _ _ uclamp_min |
---|
| 4188 | + * | | | | | | | |
---|
| 4189 | + * | | | | | | | (region c, boosted, util < uclamp_min) |
---|
| 4190 | + * +---------------------------------------- |
---|
| 4191 | + * cpu0 cpu1 cpu2 |
---|
| 4192 | + * |
---|
| 4193 | + * a) If util > uclamp_max, then we're capped, we don't care about |
---|
| 4194 | + * actual fitness value here. We only care if uclamp_max fits |
---|
| 4195 | + * capacity without taking margin/pressure into account. |
---|
| 4196 | + * See comment above. |
---|
| 4197 | + * |
---|
| 4198 | + * b) If uclamp_min <= util <= uclamp_max, then the normal |
---|
| 4199 | + * fits_capacity() rules apply. Except we need to ensure that we |
---|
| 4200 | + * enforce we remain within uclamp_max, see comment above. |
---|
| 4201 | + * |
---|
| 4202 | + * c) If util < uclamp_min, then we are boosted. Same as (b) but we |
---|
| 4203 | + * need to take into account the boosted value fits the CPU without |
---|
| 4204 | + * taking margin/pressure into account. |
---|
| 4205 | + * |
---|
| 4206 | + * Cases (a) and (b) are handled in the 'fits' variable already. We |
---|
| 4207 | + * just need to consider an extra check for case (c) after ensuring we |
---|
| 4208 | + * handle the case uclamp_min > uclamp_max. |
---|
| 4209 | + */ |
---|
| 4210 | + uclamp_min = min(uclamp_min, uclamp_max); |
---|
| 4211 | + if (util < uclamp_min && capacity_orig != SCHED_CAPACITY_SCALE) |
---|
| 4212 | + fits = fits && (uclamp_min <= capacity_orig_thermal); |
---|
| 4213 | + |
---|
| 4214 | + return fits; |
---|
| 4215 | +} |
---|
| 4216 | + |
---|
| 4217 | +static inline int task_fits_cpu(struct task_struct *p, int cpu) |
---|
| 4218 | +{ |
---|
| 4219 | + unsigned long uclamp_min = uclamp_eff_value(p, UCLAMP_MIN); |
---|
| 4220 | + unsigned long uclamp_max = uclamp_eff_value(p, UCLAMP_MAX); |
---|
| 4221 | + unsigned long util = task_util_est(p); |
---|
| 4222 | + return util_fits_cpu(util, uclamp_min, uclamp_max, cpu); |
---|
4095 | 4223 | } |
---|
4096 | 4224 | |
---|
4097 | 4225 | static inline void update_misfit_status(struct task_struct *p, struct rq *rq) |
---|
.. | .. |
---|
4107 | 4235 | return; |
---|
4108 | 4236 | } |
---|
4109 | 4237 | |
---|
4110 | | - if (task_fits_capacity(p, capacity_of(cpu_of(rq)))) { |
---|
| 4238 | + if (task_fits_cpu(p, cpu_of(rq))) { |
---|
4111 | 4239 | rq->misfit_task_load = 0; |
---|
4112 | 4240 | return; |
---|
4113 | 4241 | } |
---|
.. | .. |
---|
4168 | 4296 | #endif |
---|
4169 | 4297 | } |
---|
4170 | 4298 | |
---|
| 4299 | +static inline bool entity_is_long_sleeper(struct sched_entity *se) |
---|
| 4300 | +{ |
---|
| 4301 | + struct cfs_rq *cfs_rq; |
---|
| 4302 | + u64 sleep_time; |
---|
| 4303 | + |
---|
| 4304 | + if (se->exec_start == 0) |
---|
| 4305 | + return false; |
---|
| 4306 | + |
---|
| 4307 | + cfs_rq = cfs_rq_of(se); |
---|
| 4308 | + |
---|
| 4309 | + sleep_time = rq_clock_task(rq_of(cfs_rq)); |
---|
| 4310 | + |
---|
| 4311 | + /* Happen while migrating because of clock task divergence */ |
---|
| 4312 | + if (sleep_time <= se->exec_start) |
---|
| 4313 | + return false; |
---|
| 4314 | + |
---|
| 4315 | + sleep_time -= se->exec_start; |
---|
| 4316 | + if (sleep_time > ((1ULL << 63) / scale_load_down(NICE_0_LOAD))) |
---|
| 4317 | + return true; |
---|
| 4318 | + |
---|
| 4319 | + return false; |
---|
| 4320 | +} |
---|
| 4321 | + |
---|
4171 | 4322 | static void |
---|
4172 | 4323 | place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int initial) |
---|
4173 | 4324 | { |
---|
.. | .. |
---|
4196 | 4347 | vruntime -= thresh; |
---|
4197 | 4348 | } |
---|
4198 | 4349 | |
---|
4199 | | - /* ensure we never gain time by being placed backwards. */ |
---|
4200 | | - se->vruntime = max_vruntime(se->vruntime, vruntime); |
---|
| 4350 | + /* |
---|
| 4351 | + * Pull vruntime of the entity being placed to the base level of |
---|
| 4352 | + * cfs_rq, to prevent boosting it if placed backwards. |
---|
| 4353 | + * However, min_vruntime can advance much faster than real time, with |
---|
| 4354 | + * the extreme being when an entity with the minimal weight always runs |
---|
| 4355 | + * on the cfs_rq. If the waking entity slept for a long time, its |
---|
| 4356 | + * vruntime difference from min_vruntime may overflow s64 and their |
---|
| 4357 | + * comparison may get inversed, so ignore the entity's original |
---|
| 4358 | + * vruntime in that case. |
---|
| 4359 | + * The maximal vruntime speedup is given by the ratio of normal to |
---|
| 4360 | + * minimal weight: scale_load_down(NICE_0_LOAD) / MIN_SHARES. |
---|
| 4361 | + * When placing a migrated waking entity, its exec_start has been set |
---|
| 4362 | + * from a different rq. In order to take into account a possible |
---|
| 4363 | + * divergence between new and prev rq's clocks task because of irq and |
---|
| 4364 | + * stolen time, we take an additional margin. |
---|
| 4365 | + * So, cutting off on the sleep time of |
---|
| 4366 | + * 2^63 / scale_load_down(NICE_0_LOAD) ~ 104 days |
---|
| 4367 | + * should be safe. |
---|
| 4368 | + */ |
---|
| 4369 | + if (entity_is_long_sleeper(se)) |
---|
| 4370 | + se->vruntime = vruntime; |
---|
| 4371 | + else |
---|
| 4372 | + se->vruntime = max_vruntime(se->vruntime, vruntime); |
---|
4201 | 4373 | trace_android_rvh_place_entity(cfs_rq, se, initial, vruntime); |
---|
4202 | 4374 | } |
---|
4203 | 4375 | |
---|
.. | .. |
---|
4294 | 4466 | |
---|
4295 | 4467 | if (flags & ENQUEUE_WAKEUP) |
---|
4296 | 4468 | place_entity(cfs_rq, se, 0); |
---|
| 4469 | + /* Entity has migrated, no longer consider this task hot */ |
---|
| 4470 | + if (flags & ENQUEUE_MIGRATED) |
---|
| 4471 | + se->exec_start = 0; |
---|
4297 | 4472 | |
---|
4298 | 4473 | check_schedstat_required(); |
---|
4299 | 4474 | update_stats_enqueue(cfs_rq, se, flags); |
---|
.. | .. |
---|
5514 | 5689 | |
---|
5515 | 5690 | static inline bool cpu_overutilized(int cpu) |
---|
5516 | 5691 | { |
---|
| 5692 | + unsigned long rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN); |
---|
| 5693 | + unsigned long rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX); |
---|
5517 | 5694 | int overutilized = -1; |
---|
5518 | 5695 | |
---|
5519 | 5696 | trace_android_rvh_cpu_overutilized(cpu, &overutilized); |
---|
5520 | 5697 | if (overutilized != -1) |
---|
5521 | 5698 | return overutilized; |
---|
5522 | 5699 | |
---|
5523 | | - return !fits_capacity(cpu_util(cpu), capacity_of(cpu)); |
---|
| 5700 | + return !util_fits_cpu(cpu_util(cpu), rq_util_min, rq_util_max, cpu); |
---|
5524 | 5701 | } |
---|
5525 | 5702 | |
---|
5526 | 5703 | static inline void update_overutilized_status(struct rq *rq) |
---|
.. | .. |
---|
6262 | 6439 | static int |
---|
6263 | 6440 | select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target) |
---|
6264 | 6441 | { |
---|
6265 | | - unsigned long task_util, best_cap = 0; |
---|
| 6442 | + unsigned long task_util, util_min, util_max, best_cap = 0; |
---|
6266 | 6443 | int cpu, best_cpu = -1; |
---|
6267 | 6444 | struct cpumask *cpus; |
---|
6268 | 6445 | |
---|
6269 | 6446 | cpus = this_cpu_cpumask_var_ptr(select_idle_mask); |
---|
6270 | 6447 | cpumask_and(cpus, sched_domain_span(sd), p->cpus_ptr); |
---|
6271 | 6448 | |
---|
6272 | | - task_util = uclamp_task_util(p); |
---|
| 6449 | + task_util = task_util_est(p); |
---|
| 6450 | + util_min = uclamp_eff_value(p, UCLAMP_MIN); |
---|
| 6451 | + util_max = uclamp_eff_value(p, UCLAMP_MAX); |
---|
6273 | 6452 | |
---|
6274 | 6453 | for_each_cpu_wrap(cpu, cpus, target) { |
---|
6275 | 6454 | unsigned long cpu_cap = capacity_of(cpu); |
---|
6276 | 6455 | |
---|
6277 | 6456 | if (!available_idle_cpu(cpu) && !sched_idle_cpu(cpu)) |
---|
6278 | 6457 | continue; |
---|
6279 | | - if (fits_capacity(task_util, cpu_cap)) |
---|
| 6458 | + if (util_fits_cpu(task_util, util_min, util_max, cpu)) |
---|
6280 | 6459 | return cpu; |
---|
6281 | 6460 | |
---|
6282 | 6461 | if (cpu_cap > best_cap) { |
---|
.. | .. |
---|
6288 | 6467 | return best_cpu; |
---|
6289 | 6468 | } |
---|
6290 | 6469 | |
---|
6291 | | -static inline bool asym_fits_capacity(int task_util, int cpu) |
---|
| 6470 | +static inline bool asym_fits_cpu(unsigned long util, |
---|
| 6471 | + unsigned long util_min, |
---|
| 6472 | + unsigned long util_max, |
---|
| 6473 | + int cpu) |
---|
6292 | 6474 | { |
---|
6293 | 6475 | if (static_branch_unlikely(&sched_asym_cpucapacity)) |
---|
6294 | | - return fits_capacity(task_util, capacity_of(cpu)); |
---|
| 6476 | + return util_fits_cpu(util, util_min, util_max, cpu); |
---|
6295 | 6477 | |
---|
6296 | 6478 | return true; |
---|
6297 | 6479 | } |
---|
.. | .. |
---|
6302 | 6484 | static int select_idle_sibling(struct task_struct *p, int prev, int target) |
---|
6303 | 6485 | { |
---|
6304 | 6486 | struct sched_domain *sd; |
---|
6305 | | - unsigned long task_util; |
---|
| 6487 | + unsigned long task_util, util_min, util_max; |
---|
6306 | 6488 | int i, recent_used_cpu; |
---|
6307 | 6489 | |
---|
6308 | 6490 | /* |
---|
.. | .. |
---|
6311 | 6493 | */ |
---|
6312 | 6494 | if (static_branch_unlikely(&sched_asym_cpucapacity)) { |
---|
6313 | 6495 | sync_entity_load_avg(&p->se); |
---|
6314 | | - task_util = uclamp_task_util(p); |
---|
| 6496 | + task_util = task_util_est(p); |
---|
| 6497 | + util_min = uclamp_eff_value(p, UCLAMP_MIN); |
---|
| 6498 | + util_max = uclamp_eff_value(p, UCLAMP_MAX); |
---|
6315 | 6499 | } |
---|
6316 | 6500 | |
---|
6317 | 6501 | if ((available_idle_cpu(target) || sched_idle_cpu(target)) && |
---|
6318 | | - asym_fits_capacity(task_util, target)) |
---|
| 6502 | + asym_fits_cpu(task_util, util_min, util_max, target)) |
---|
6319 | 6503 | return target; |
---|
6320 | 6504 | |
---|
6321 | 6505 | /* |
---|
.. | .. |
---|
6323 | 6507 | */ |
---|
6324 | 6508 | if (prev != target && cpus_share_cache(prev, target) && |
---|
6325 | 6509 | (available_idle_cpu(prev) || sched_idle_cpu(prev)) && |
---|
6326 | | - asym_fits_capacity(task_util, prev)) |
---|
| 6510 | + asym_fits_cpu(task_util, util_min, util_max, prev)) |
---|
6327 | 6511 | return prev; |
---|
6328 | 6512 | |
---|
6329 | 6513 | /* |
---|
.. | .. |
---|
6338 | 6522 | in_task() && |
---|
6339 | 6523 | prev == smp_processor_id() && |
---|
6340 | 6524 | this_rq()->nr_running <= 1 && |
---|
6341 | | - asym_fits_capacity(task_util, prev)) { |
---|
| 6525 | + asym_fits_cpu(task_util, util_min, util_max, prev)) { |
---|
6342 | 6526 | return prev; |
---|
6343 | 6527 | } |
---|
6344 | 6528 | |
---|
.. | .. |
---|
6349 | 6533 | cpus_share_cache(recent_used_cpu, target) && |
---|
6350 | 6534 | (available_idle_cpu(recent_used_cpu) || sched_idle_cpu(recent_used_cpu)) && |
---|
6351 | 6535 | cpumask_test_cpu(p->recent_used_cpu, p->cpus_ptr) && |
---|
6352 | | - asym_fits_capacity(task_util, recent_used_cpu)) { |
---|
| 6536 | + asym_fits_cpu(task_util, util_min, util_max, recent_used_cpu)) { |
---|
6353 | 6537 | /* |
---|
6354 | 6538 | * Replace recent_used_cpu with prev as it is a potential |
---|
6355 | 6539 | * candidate for the next wake: |
---|
.. | .. |
---|
6682 | 6866 | { |
---|
6683 | 6867 | unsigned long prev_delta = ULONG_MAX, best_delta = ULONG_MAX; |
---|
6684 | 6868 | unsigned long best_delta2 = ULONG_MAX; |
---|
| 6869 | + unsigned long p_util_min = uclamp_is_used() ? uclamp_eff_value(p, UCLAMP_MIN) : 0; |
---|
| 6870 | + unsigned long p_util_max = uclamp_is_used() ? uclamp_eff_value(p, UCLAMP_MAX) : 1024; |
---|
6685 | 6871 | struct root_domain *rd = cpu_rq(smp_processor_id())->rd; |
---|
6686 | 6872 | int max_spare_cap_cpu_ls = prev_cpu, best_idle_cpu = -1; |
---|
6687 | 6873 | unsigned long max_spare_cap_ls = 0, target_cap; |
---|
.. | .. |
---|
6707 | 6893 | cpu = smp_processor_id(); |
---|
6708 | 6894 | if (sync && cpu_rq(cpu)->nr_running == 1 && |
---|
6709 | 6895 | cpumask_test_cpu(cpu, p->cpus_ptr) && |
---|
6710 | | - task_fits_capacity(p, capacity_of(cpu))) { |
---|
| 6896 | + task_fits_cpu(p, cpu)) { |
---|
6711 | 6897 | rcu_read_unlock(); |
---|
6712 | 6898 | return cpu; |
---|
6713 | 6899 | } |
---|
.. | .. |
---|
6722 | 6908 | if (!sd) |
---|
6723 | 6909 | goto fail; |
---|
6724 | 6910 | |
---|
6725 | | - if (!task_util_est(p)) |
---|
| 6911 | + if (!uclamp_task_util(p, p_util_min, p_util_max)) |
---|
6726 | 6912 | goto unlock; |
---|
6727 | 6913 | |
---|
6728 | 6914 | latency_sensitive = uclamp_latency_sensitive(p); |
---|
.. | .. |
---|
6731 | 6917 | |
---|
6732 | 6918 | for (; pd; pd = pd->next) { |
---|
6733 | 6919 | unsigned long cur_delta, spare_cap, max_spare_cap = 0; |
---|
| 6920 | + unsigned long rq_util_min, rq_util_max; |
---|
| 6921 | + unsigned long util_min, util_max; |
---|
6734 | 6922 | unsigned long base_energy_pd; |
---|
6735 | 6923 | int max_spare_cap_cpu = -1; |
---|
6736 | 6924 | |
---|
.. | .. |
---|
6754 | 6942 | * much capacity we can get out of the CPU; this is |
---|
6755 | 6943 | * aligned with schedutil_cpu_util(). |
---|
6756 | 6944 | */ |
---|
6757 | | - util = uclamp_rq_util_with(cpu_rq(cpu), util, p); |
---|
6758 | | - if (!fits_capacity(util, cpu_cap)) |
---|
| 6945 | + if (uclamp_is_used()) { |
---|
| 6946 | + if (uclamp_rq_is_idle(cpu_rq(cpu))) { |
---|
| 6947 | + util_min = p_util_min; |
---|
| 6948 | + util_max = p_util_max; |
---|
| 6949 | + } else { |
---|
| 6950 | + /* |
---|
| 6951 | + * Open code uclamp_rq_util_with() except for |
---|
| 6952 | + * the clamp() part. Ie: apply max aggregation |
---|
| 6953 | + * only. util_fits_cpu() logic requires to |
---|
| 6954 | + * operate on non clamped util but must use the |
---|
| 6955 | + * max-aggregated uclamp_{min, max}. |
---|
| 6956 | + */ |
---|
| 6957 | + rq_util_min = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MIN); |
---|
| 6958 | + rq_util_max = uclamp_rq_get(cpu_rq(cpu), UCLAMP_MAX); |
---|
| 6959 | + |
---|
| 6960 | + util_min = max(rq_util_min, p_util_min); |
---|
| 6961 | + util_max = max(rq_util_max, p_util_max); |
---|
| 6962 | + } |
---|
| 6963 | + } |
---|
| 6964 | + if (!util_fits_cpu(util, util_min, util_max, cpu)) |
---|
6759 | 6965 | continue; |
---|
6760 | 6966 | |
---|
6761 | 6967 | /* Always use prev_cpu as a candidate. */ |
---|
.. | .. |
---|
7034 | 7240 | |
---|
7035 | 7241 | /* Tell new CPU we are migrated */ |
---|
7036 | 7242 | p->se.avg.last_update_time = 0; |
---|
7037 | | - |
---|
7038 | | - /* We have migrated, no longer consider this task hot */ |
---|
7039 | | - p->se.exec_start = 0; |
---|
7040 | 7243 | |
---|
7041 | 7244 | update_scan_period(p, new_cpu); |
---|
7042 | 7245 | } |
---|
.. | .. |
---|
7983 | 8186 | |
---|
7984 | 8187 | case migrate_misfit: |
---|
7985 | 8188 | /* This is not a misfit task */ |
---|
7986 | | - if (task_fits_capacity(p, capacity_of(env->src_cpu))) |
---|
| 8189 | + if (task_fits_cpu(p, env->src_cpu)) |
---|
7987 | 8190 | goto next; |
---|
7988 | 8191 | |
---|
7989 | 8192 | env->imbalance = 0; |
---|
.. | .. |
---|
8926 | 9129 | |
---|
8927 | 9130 | memset(sgs, 0, sizeof(*sgs)); |
---|
8928 | 9131 | |
---|
| 9132 | + /* Assume that task can't fit any CPU of the group */ |
---|
| 9133 | + if (sd->flags & SD_ASYM_CPUCAPACITY) |
---|
| 9134 | + sgs->group_misfit_task_load = 1; |
---|
| 9135 | + |
---|
8929 | 9136 | for_each_cpu(i, sched_group_span(group)) { |
---|
8930 | 9137 | struct rq *rq = cpu_rq(i); |
---|
8931 | 9138 | unsigned int local; |
---|
.. | .. |
---|
8945 | 9152 | if (!nr_running && idle_cpu_without(i, p)) |
---|
8946 | 9153 | sgs->idle_cpus++; |
---|
8947 | 9154 | |
---|
8948 | | - } |
---|
| 9155 | + /* Check if task fits in the CPU */ |
---|
| 9156 | + if (sd->flags & SD_ASYM_CPUCAPACITY && |
---|
| 9157 | + sgs->group_misfit_task_load && |
---|
| 9158 | + task_fits_cpu(p, i)) |
---|
| 9159 | + sgs->group_misfit_task_load = 0; |
---|
8949 | 9160 | |
---|
8950 | | - /* Check if task fits in the group */ |
---|
8951 | | - if (sd->flags & SD_ASYM_CPUCAPACITY && |
---|
8952 | | - !task_fits_capacity(p, group->sgc->max_capacity)) { |
---|
8953 | | - sgs->group_misfit_task_load = 1; |
---|
8954 | 9161 | } |
---|
8955 | 9162 | |
---|
8956 | 9163 | sgs->group_capacity = group->sgc->capacity; |
---|
.. | .. |
---|
9395 | 9602 | local->avg_load = (local->group_load * SCHED_CAPACITY_SCALE) / |
---|
9396 | 9603 | local->group_capacity; |
---|
9397 | 9604 | |
---|
9398 | | - sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) / |
---|
9399 | | - sds->total_capacity; |
---|
9400 | 9605 | /* |
---|
9401 | 9606 | * If the local group is more loaded than the selected |
---|
9402 | 9607 | * busiest group don't try to pull any tasks. |
---|
.. | .. |
---|
9405 | 9610 | env->imbalance = 0; |
---|
9406 | 9611 | return; |
---|
9407 | 9612 | } |
---|
| 9613 | + |
---|
| 9614 | + sds->avg_load = (sds->total_load * SCHED_CAPACITY_SCALE) / |
---|
| 9615 | + sds->total_capacity; |
---|
| 9616 | + |
---|
| 9617 | + /* |
---|
| 9618 | + * If the local group is more loaded than the average system |
---|
| 9619 | + * load, don't try to pull any tasks. |
---|
| 9620 | + */ |
---|
| 9621 | + if (local->avg_load >= sds->avg_load) { |
---|
| 9622 | + env->imbalance = 0; |
---|
| 9623 | + return; |
---|
| 9624 | + } |
---|
| 9625 | + |
---|
9408 | 9626 | } |
---|
9409 | 9627 | |
---|
9410 | 9628 | /* |
---|
.. | .. |
---|
9837 | 10055 | .sd = sd, |
---|
9838 | 10056 | .dst_cpu = this_cpu, |
---|
9839 | 10057 | .dst_rq = this_rq, |
---|
9840 | | - .dst_grpmask = sched_group_span(sd->groups), |
---|
| 10058 | + .dst_grpmask = group_balance_mask(sd->groups), |
---|
9841 | 10059 | .idle = idle, |
---|
9842 | 10060 | .loop_break = sched_nr_migrate_break, |
---|
9843 | 10061 | .cpus = cpus, |
---|