Skip to content

Commit a2e9061

Browse files
vingu-linaroPeter Zijlstra
authored andcommitted
sched/fair: Remove capacity inversion detection
Remove the capacity inversion detection which is now handled by util_fits_cpu() returning -1 when we need to continue to look for a potential CPU with better performance. This ends up almost reverting patches below except for some comments: commit da07d2f ("sched/fair: Fixes for capacity inversion detection") commit aa69c36 ("sched/fair: Consider capacity inversion in util_fits_cpu()") commit 44c7b80 ("sched/fair: Detect capacity inversion") Signed-off-by: Vincent Guittot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent e5ed055 commit a2e9061

File tree

2 files changed

+5
-98
lines changed

2 files changed

+5
-98
lines changed

kernel/sched/fair.c

Lines changed: 5 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4476,17 +4476,9 @@ static inline int util_fits_cpu(unsigned long util,
44764476
*
44774477
* For uclamp_max, we can tolerate a drop in performance level as the
44784478
* goal is to cap the task. So it's okay if it's getting less.
4479-
*
4480-
* In case of capacity inversion we should honour the inverted capacity
4481-
* for both uclamp_min and uclamp_max all the time.
44824479
*/
4483-
capacity_orig = cpu_in_capacity_inversion(cpu);
4484-
if (capacity_orig) {
4485-
capacity_orig_thermal = capacity_orig;
4486-
} else {
4487-
capacity_orig = capacity_orig_of(cpu);
4488-
capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure(cpu);
4489-
}
4480+
capacity_orig = capacity_orig_of(cpu);
4481+
capacity_orig_thermal = capacity_orig - arch_scale_thermal_pressure(cpu);
44904482

44914483
/*
44924484
* We want to force a task to fit a cpu as implied by uclamp_max.
@@ -9027,82 +9019,16 @@ static unsigned long scale_rt_capacity(int cpu)
90279019

90289020
static void update_cpu_capacity(struct sched_domain *sd, int cpu)
90299021
{
9030-
unsigned long capacity_orig = arch_scale_cpu_capacity(cpu);
90319022
unsigned long capacity = scale_rt_capacity(cpu);
90329023
struct sched_group *sdg = sd->groups;
9033-
struct rq *rq = cpu_rq(cpu);
90349024

9035-
rq->cpu_capacity_orig = capacity_orig;
9025+
cpu_rq(cpu)->cpu_capacity_orig = arch_scale_cpu_capacity(cpu);
90369026

90379027
if (!capacity)
90389028
capacity = 1;
90399029

9040-
rq->cpu_capacity = capacity;
9041-
9042-
/*
9043-
* Detect if the performance domain is in capacity inversion state.
9044-
*
9045-
* Capacity inversion happens when another perf domain with equal or
9046-
* lower capacity_orig_of() ends up having higher capacity than this
9047-
* domain after subtracting thermal pressure.
9048-
*
9049-
* We only take into account thermal pressure in this detection as it's
9050-
* the only metric that actually results in *real* reduction of
9051-
* capacity due to performance points (OPPs) being dropped/become
9052-
* unreachable due to thermal throttling.
9053-
*
9054-
* We assume:
9055-
* * That all cpus in a perf domain have the same capacity_orig
9056-
* (same uArch).
9057-
* * Thermal pressure will impact all cpus in this perf domain
9058-
* equally.
9059-
*/
9060-
if (sched_energy_enabled()) {
9061-
unsigned long inv_cap = capacity_orig - thermal_load_avg(rq);
9062-
struct perf_domain *pd;
9063-
9064-
rcu_read_lock();
9065-
9066-
pd = rcu_dereference(rq->rd->pd);
9067-
rq->cpu_capacity_inverted = 0;
9068-
9069-
for (; pd; pd = pd->next) {
9070-
struct cpumask *pd_span = perf_domain_span(pd);
9071-
unsigned long pd_cap_orig, pd_cap;
9072-
9073-
/* We can't be inverted against our own pd */
9074-
if (cpumask_test_cpu(cpu_of(rq), pd_span))
9075-
continue;
9076-
9077-
cpu = cpumask_any(pd_span);
9078-
pd_cap_orig = arch_scale_cpu_capacity(cpu);
9079-
9080-
if (capacity_orig < pd_cap_orig)
9081-
continue;
9082-
9083-
/*
9084-
* handle the case of multiple perf domains have the
9085-
* same capacity_orig but one of them is under higher
9086-
* thermal pressure. We record it as capacity
9087-
* inversion.
9088-
*/
9089-
if (capacity_orig == pd_cap_orig) {
9090-
pd_cap = pd_cap_orig - thermal_load_avg(cpu_rq(cpu));
9091-
9092-
if (pd_cap > inv_cap) {
9093-
rq->cpu_capacity_inverted = inv_cap;
9094-
break;
9095-
}
9096-
} else if (pd_cap_orig > inv_cap) {
9097-
rq->cpu_capacity_inverted = inv_cap;
9098-
break;
9099-
}
9100-
}
9101-
9102-
rcu_read_unlock();
9103-
}
9104-
9105-
trace_sched_cpu_capacity_tp(rq);
9030+
cpu_rq(cpu)->cpu_capacity = capacity;
9031+
trace_sched_cpu_capacity_tp(cpu_rq(cpu));
91069032

91079033
sdg->sgc->capacity = capacity;
91089034
sdg->sgc->min_capacity = capacity;

kernel/sched/sched.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,6 @@ struct rq {
10441044

10451045
unsigned long cpu_capacity;
10461046
unsigned long cpu_capacity_orig;
1047-
unsigned long cpu_capacity_inverted;
10481047

10491048
struct balance_callback *balance_callback;
10501049

@@ -2899,24 +2898,6 @@ static inline unsigned long capacity_orig_of(int cpu)
28992898
return cpu_rq(cpu)->cpu_capacity_orig;
29002899
}
29012900

2902-
/*
2903-
* Returns inverted capacity if the CPU is in capacity inversion state.
2904-
* 0 otherwise.
2905-
*
2906-
* Capacity inversion detection only considers thermal impact where actual
2907-
* performance points (OPPs) gets dropped.
2908-
*
2909-
* Capacity inversion state happens when another performance domain that has
2910-
* equal or lower capacity_orig_of() becomes effectively larger than the perf
2911-
* domain this CPU belongs to due to thermal pressure throttling it hard.
2912-
*
2913-
* See comment in update_cpu_capacity().
2914-
*/
2915-
static inline unsigned long cpu_in_capacity_inversion(int cpu)
2916-
{
2917-
return cpu_rq(cpu)->cpu_capacity_inverted;
2918-
}
2919-
29202901
/**
29212902
* enum cpu_util_type - CPU utilization type
29222903
* @FREQUENCY_UTIL: Utilization used to select frequency

0 commit comments

Comments
 (0)