@@ -4965,13 +4965,22 @@ static inline void util_est_update(struct cfs_rq *cfs_rq,
4965
4965
trace_sched_util_est_se_tp (& p -> se );
4966
4966
}
4967
4967
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
+
4968
4977
static inline int util_fits_cpu (unsigned long util ,
4969
4978
unsigned long uclamp_min ,
4970
4979
unsigned long uclamp_max ,
4971
4980
int cpu )
4972
4981
{
4973
- unsigned long capacity_orig , capacity_orig_thermal ;
4974
4982
unsigned long capacity = capacity_of (cpu );
4983
+ unsigned long capacity_orig ;
4975
4984
bool fits , uclamp_max_fits ;
4976
4985
4977
4986
/*
@@ -5003,7 +5012,6 @@ static inline int util_fits_cpu(unsigned long util,
5003
5012
* goal is to cap the task. So it's okay if it's getting less.
5004
5013
*/
5005
5014
capacity_orig = arch_scale_cpu_capacity (cpu );
5006
- capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure (cpu );
5007
5015
5008
5016
/*
5009
5017
* 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,
5078
5086
* handle the case uclamp_min > uclamp_max.
5079
5087
*/
5080
5088
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 )))
5082
5091
return -1 ;
5083
5092
5084
5093
return fits ;
@@ -7494,7 +7503,7 @@ select_idle_capacity(struct task_struct *p, struct sched_domain *sd, int target)
7494
7503
* Look for the CPU with best capacity.
7495
7504
*/
7496
7505
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 );
7498
7507
7499
7508
/*
7500
7509
* 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)
7987
7996
struct root_domain * rd = this_rq ()-> rd ;
7988
7997
int cpu , best_energy_cpu , target = -1 ;
7989
7998
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 ;
7992
8001
struct sched_domain * sd ;
7993
8002
struct perf_domain * pd ;
7994
8003
struct energy_env eenv ;
@@ -8018,7 +8027,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
8018
8027
8019
8028
for (; pd ; pd = pd -> next ) {
8020
8029
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 ;
8022
8031
long prev_spare_cap = -1 , max_spare_cap = -1 ;
8023
8032
unsigned long rq_util_min , rq_util_max ;
8024
8033
unsigned long cur_delta , base_energy ;
@@ -8030,18 +8039,17 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
8030
8039
if (cpumask_empty (cpus ))
8031
8040
continue ;
8032
8041
8033
- /* Account thermal pressure for the energy estimation */
8042
+ /* Account external pressure for the energy estimation */
8034
8043
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 );
8037
8045
8038
- eenv .cpu_cap = cpu_thermal_cap ;
8046
+ eenv .cpu_cap = cpu_actual_cap ;
8039
8047
eenv .pd_cap = 0 ;
8040
8048
8041
8049
for_each_cpu (cpu , cpus ) {
8042
8050
struct rq * rq = cpu_rq (cpu );
8043
8051
8044
- eenv .pd_cap += cpu_thermal_cap ;
8052
+ eenv .pd_cap += cpu_actual_cap ;
8045
8053
8046
8054
if (!cpumask_test_cpu (cpu , sched_domain_span (sd )))
8047
8055
continue ;
@@ -8112,7 +8120,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
8112
8120
if (prev_delta < base_energy )
8113
8121
goto unlock ;
8114
8122
prev_delta -= base_energy ;
8115
- prev_thermal_cap = cpu_thermal_cap ;
8123
+ prev_actual_cap = cpu_actual_cap ;
8116
8124
best_delta = min (best_delta , prev_delta );
8117
8125
}
8118
8126
@@ -8127,7 +8135,7 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
8127
8135
* but best energy cpu has better capacity.
8128
8136
*/
8129
8137
if ((max_fits < 0 ) &&
8130
- (cpu_thermal_cap <= best_thermal_cap ))
8138
+ (cpu_actual_cap <= best_actual_cap ))
8131
8139
continue ;
8132
8140
8133
8141
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)
8148
8156
best_delta = cur_delta ;
8149
8157
best_energy_cpu = max_spare_cap_cpu ;
8150
8158
best_fits = max_fits ;
8151
- best_thermal_cap = cpu_thermal_cap ;
8159
+ best_actual_cap = cpu_actual_cap ;
8152
8160
}
8153
8161
}
8154
8162
rcu_read_unlock ();
8155
8163
8156
8164
if ((best_fits > prev_fits ) ||
8157
8165
((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 )))
8159
8167
target = best_energy_cpu ;
8160
8168
8161
8169
return target ;
@@ -9560,8 +9568,8 @@ static inline void init_sd_lb_stats(struct sd_lb_stats *sds)
9560
9568
9561
9569
static unsigned long scale_rt_capacity (int cpu )
9562
9570
{
9571
+ unsigned long max = get_actual_cpu_capacity (cpu );
9563
9572
struct rq * rq = cpu_rq (cpu );
9564
- unsigned long max = arch_scale_cpu_capacity (cpu );
9565
9573
unsigned long used , free ;
9566
9574
unsigned long irq ;
9567
9575
@@ -9573,12 +9581,9 @@ static unsigned long scale_rt_capacity(int cpu)
9573
9581
/*
9574
9582
* avg_rt.util_avg and avg_dl.util_avg track binary signals
9575
9583
* (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).
9578
9584
*/
9579
9585
used = cpu_util_rt (rq );
9580
9586
used += cpu_util_dl (rq );
9581
- used += thermal_load_avg (rq );
9582
9587
9583
9588
if (unlikely (used >= max ))
9584
9589
return 1 ;
0 commit comments