Skip to content

Commit ab4dd38

Browse files
derklingpundiramit
authored andcommitted
sched/fair: consider task utilization in group_max_util()
The group_max_util() function is used to compute the maximum utilization across the CPUs of a certain energy_env configuration. Its main client is the energy_diff function when it needs to compute the SG capacity for one of the before/after scheduling candidates. Currently, the energy_diff function sets util_delta = 0 when it wants to compute the energy corresponding to the scheduling candidate where the task runs in the previous CPU. This implies that, for the task waking up in the previous CPU we consider only its blocked load tracked by the CPU RQ. However, in case of a medium-big task which is waking up on a long time idle CPU, this blocked load can be already completely decayed. More in general, the current approach is biased towards under-estimating the capacity requirements for the "before" scheduling candidate. This patch fixes this by: - always use the cpu_util_wake() to properly get the utilization of a CPU without any (partially decayed) contribution of the waking up task - adding the task utilization to the cpu_util_wake just for the target cpu The "target CPU" is defined by the energy_env to be either the src_cpu or the dst_cpu, depending on which scheduling candidate we are considering. Finally, since this update removes the last usage of calc_util_delta() this function is now safely removed. Change-Id: I20ee1bcf40cee6bf6e265fb2d32ef79061ad6ced Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com> Signed-off-by: Chris Redpath <chris.redpath@arm.com>
1 parent df0d98c commit ab4dd38

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

kernel/sched/fair.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5339,24 +5339,24 @@ static unsigned long __cpu_norm_util(unsigned long util, unsigned long capacity)
53395339
return (util << SCHED_CAPACITY_SHIFT)/capacity;
53405340
}
53415341

5342-
static int calc_util_delta(struct energy_env *eenv, int cpu)
5342+
static unsigned long group_max_util(struct energy_env *eenv)
53435343
{
5344-
if (cpu == eenv->src_cpu)
5345-
return -eenv->util_delta;
5346-
if (cpu == eenv->dst_cpu)
5347-
return eenv->util_delta;
5348-
return 0;
5349-
}
5350-
5351-
static
5352-
unsigned long group_max_util(struct energy_env *eenv)
5353-
{
5354-
int i, delta;
53555344
unsigned long max_util = 0;
5345+
unsigned long util;
5346+
int cpu;
5347+
5348+
for_each_cpu(cpu, sched_group_cpus(eenv->sg_cap)) {
5349+
util = cpu_util_wake(cpu, eenv->task);
5350+
5351+
/*
5352+
* If we are looking at the target CPU specified by the eenv,
5353+
* then we should add the (estimated) utilization of the task
5354+
* assuming we will wake it up on that CPU.
5355+
*/
5356+
if (unlikely(cpu == eenv->trg_cpu))
5357+
util += eenv->util_delta;
53565358

5357-
for_each_cpu(i, sched_group_cpus(eenv->sg_cap)) {
5358-
delta = calc_util_delta(eenv, i);
5359-
max_util = max(max_util, __cpu_util(i, delta));
5359+
max_util = max(max_util, util);
53605360
}
53615361

53625362
return max_util;

0 commit comments

Comments
 (0)