@@ -4965,13 +4965,22 @@ static inline void util_est_update(struct cfs_rq *cfs_rq,
49654965 trace_sched_util_est_se_tp (& p -> se );
49664966}
49674967
4968+ static inline unsigned long get_actual_cpu_capacity (int cpu )
4969+ {
4970+ unsigned long capacity = arch_scale_cpu_capacity (cpu );
4971+
4972+ capacity -= max (thermal_load_avg (cpu_rq (cpu )), cpufreq_get_pressure (cpu ));
4973+
4974+ return capacity ;
4975+ }
4976+
49684977static inline int util_fits_cpu (unsigned long util ,
49694978 unsigned long uclamp_min ,
49704979 unsigned long uclamp_max ,
49714980 int cpu )
49724981{
4973- unsigned long capacity_orig , capacity_orig_thermal ;
49744982 unsigned long capacity = capacity_of (cpu );
4983+ unsigned long capacity_orig ;
49754984 bool fits , uclamp_max_fits ;
49764985
49774986 /*
@@ -5003,7 +5012,6 @@ static inline int util_fits_cpu(unsigned long util,
50035012 * goal is to cap the task. So it's okay if it's getting less.
50045013 */
50055014 capacity_orig = arch_scale_cpu_capacity (cpu );
5006- capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure (cpu );
50075015
50085016 /*
50095017 * We want to force a task to fit a cpu as implied by uclamp_max.
@@ -5078,7 +5086,8 @@ static inline int util_fits_cpu(unsigned long util,
50785086 * handle the case uclamp_min > uclamp_max.
50795087 */
50805088 uclamp_min = min (uclamp_min , uclamp_max );
5081- if (fits && (util < uclamp_min ) && (uclamp_min > capacity_orig_thermal ))
5089+ if (fits && (util < uclamp_min ) &&
5090+ (uclamp_min > get_actual_cpu_capacity (cpu )))
50825091 return -1 ;
50835092
50845093 return fits ;
@@ -7494,7 +7503,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
74947503 * Look for the CPU with best capacity.
74957504 */
74967505 else if (fits < 0 )
7497- cpu_cap = arch_scale_cpu_capacity (cpu ) - thermal_load_avg ( cpu_rq ( cpu ) );
7506+ cpu_cap = get_actual_cpu_capacity (cpu );
74987507
74997508 /*
75007509 * First, select CPU which fits better (-1 being better than 0).
@@ -7987,8 +7996,8 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
79877996 struct root_domain * rd = this_rq ()-> rd ;
79887997 int cpu , best_energy_cpu , target = -1 ;
79897998 int prev_fits = -1 , best_fits = -1 ;
7990- unsigned long best_thermal_cap = 0 ;
7991- unsigned long prev_thermal_cap = 0 ;
7999+ unsigned long best_actual_cap = 0 ;
8000+ unsigned long prev_actual_cap = 0 ;
79928001 struct sched_domain * sd ;
79938002 struct perf_domain * pd ;
79948003 struct energy_env eenv ;
@@ -8018,7 +8027,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
80188027
80198028 for (; pd ; pd = pd -> next ) {
80208029 unsigned long util_min = p_util_min , util_max = p_util_max ;
8021- unsigned long cpu_cap , cpu_thermal_cap , util ;
8030+ unsigned long cpu_cap , cpu_actual_cap , util ;
80228031 long prev_spare_cap = -1 , max_spare_cap = -1 ;
80238032 unsigned long rq_util_min , rq_util_max ;
80248033 unsigned long cur_delta , base_energy ;
@@ -8030,18 +8039,17 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
80308039 if (cpumask_empty (cpus ))
80318040 continue ;
80328041
8033- /* Account thermal pressure for the energy estimation */
8042+ /* Account external pressure for the energy estimation */
80348043 cpu = cpumask_first (cpus );
8035- cpu_thermal_cap = arch_scale_cpu_capacity (cpu );
8036- cpu_thermal_cap -= arch_scale_thermal_pressure (cpu );
8044+ cpu_actual_cap = get_actual_cpu_capacity (cpu );
80378045
8038- eenv .cpu_cap = cpu_thermal_cap ;
8046+ eenv .cpu_cap = cpu_actual_cap ;
80398047 eenv .pd_cap = 0 ;
80408048
80418049 for_each_cpu (cpu , cpus ) {
80428050 struct rq * rq = cpu_rq (cpu );
80438051
8044- eenv .pd_cap += cpu_thermal_cap ;
8052+ eenv .pd_cap += cpu_actual_cap ;
80458053
80468054 if (!cpumask_test_cpu (cpu , sched_domain_span (sd )))
80478055 continue ;
@@ -8112,7 +8120,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
81128120 if (prev_delta < base_energy )
81138121 goto unlock ;
81148122 prev_delta -= base_energy ;
8115- prev_thermal_cap = cpu_thermal_cap ;
8123+ prev_actual_cap = cpu_actual_cap ;
81168124 best_delta = min (best_delta , prev_delta );
81178125 }
81188126
@@ -8127,7 +8135,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
81278135 * but best energy cpu has better capacity.
81288136 */
81298137 if ((max_fits < 0 ) &&
8130- (cpu_thermal_cap <= best_thermal_cap ))
8138+ (cpu_actual_cap <= best_actual_cap ))
81318139 continue ;
81328140
81338141 cur_delta = compute_energy (& eenv , pd , cpus , p ,
@@ -8148,14 +8156,14 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
81488156 best_delta = cur_delta ;
81498157 best_energy_cpu = max_spare_cap_cpu ;
81508158 best_fits = max_fits ;
8151- best_thermal_cap = cpu_thermal_cap ;
8159+ best_actual_cap = cpu_actual_cap ;
81528160 }
81538161 }
81548162 rcu_read_unlock ();
81558163
81568164 if ((best_fits > prev_fits ) ||
81578165 ((best_fits > 0 ) && (best_delta < prev_delta )) ||
8158- ((best_fits < 0 ) && (best_thermal_cap > prev_thermal_cap )))
8166+ ((best_fits < 0 ) && (best_actual_cap > prev_actual_cap )))
81598167 target = best_energy_cpu ;
81608168
81618169 return target ;
@@ -9560,8 +9568,8 @@ static inline void init_sd_lb_stats(struct sd_lb_stats *sds)
95609568
95619569static unsigned long scale_rt_capacity (int cpu )
95629570{
9571+ unsigned long max = get_actual_cpu_capacity (cpu );
95639572 struct rq * rq = cpu_rq (cpu );
9564- unsigned long max = arch_scale_cpu_capacity (cpu );
95659573 unsigned long used , free ;
95669574 unsigned long irq ;
95679575
@@ -9573,12 +9581,9 @@ static unsigned long scale_rt_capacity(int cpu)
95739581 /*
95749582 * avg_rt.util_avg and avg_dl.util_avg track binary signals
95759583 * (running and not running) with weights 0 and 1024 respectively.
9576- * avg_thermal.load_avg tracks thermal pressure and the weighted
9577- * average uses the actual delta max capacity(load).
95789584 */
95799585 used = cpu_util_rt (rq );
95809586 used += cpu_util_dl (rq );
9581- used += thermal_load_avg (rq );
95829587
95839588 if (unlikely (used >= max ))
95849589 return 1 ;
0 commit comments