sched/fair: consider task utilization in group_norm_util()
The group_norm_util() function is used to compute the normalized utilization of a SG given a certain energy_env configuration. The main client of this function is the energy_diff function when it comes to compute the SG energy 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 energy consumption 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. This patch update also the definition of __cpu_norm_util(), which is currently called just by the group_norm_util() function. This allows to simplify the code by using this function just to normalize a specified utilization with respect to a given capacity. This update allows to completely remove any dependency of group_norm_util() from calc_util_delta(). Change-Id: I3b6ec50ce8decb1521faae660e326ab3319d3c82 Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com> Signed-off-by: Chris Redpath <chris.redpath@arm.com>
This commit is contained in:
parent
ca42e80446
commit
5f8b3a757d
1 changed files with 36 additions and 22 deletions
|
@ -5297,6 +5297,7 @@ struct energy_env {
|
|||
int util_delta;
|
||||
int src_cpu;
|
||||
int dst_cpu;
|
||||
int trg_cpu;
|
||||
int energy;
|
||||
int payoff;
|
||||
struct task_struct *task;
|
||||
|
@ -5313,11 +5314,14 @@ struct energy_env {
|
|||
} cap;
|
||||
};
|
||||
|
||||
static int cpu_util_wake(int cpu, struct task_struct *p);
|
||||
|
||||
/*
|
||||
* __cpu_norm_util() returns the cpu util relative to a specific capacity,
|
||||
* i.e. it's busy ratio, in the range [0..SCHED_LOAD_SCALE] which is useful for
|
||||
* energy calculations. Using the scale-invariant util returned by
|
||||
* cpu_util() and approximating scale-invariant util by:
|
||||
* i.e. it's busy ratio, in the range [0..SCHED_LOAD_SCALE], which is useful for
|
||||
* energy calculations.
|
||||
*
|
||||
* Since util is a scale-invariant utilization defined as:
|
||||
*
|
||||
* util ~ (curr_freq/max_freq)*1024 * capacity_orig/1024 * running_time/time
|
||||
*
|
||||
|
@ -5327,10 +5331,8 @@ struct energy_env {
|
|||
*
|
||||
* norm_util = running_time/time ~ util/capacity
|
||||
*/
|
||||
static unsigned long __cpu_norm_util(int cpu, unsigned long capacity, int delta)
|
||||
static unsigned long __cpu_norm_util(unsigned long util, unsigned long capacity)
|
||||
{
|
||||
int util = __cpu_util(cpu, delta);
|
||||
|
||||
if (util >= capacity)
|
||||
return SCHED_CAPACITY_SCALE;
|
||||
|
||||
|
@ -5362,28 +5364,37 @@ unsigned long group_max_util(struct energy_env *eenv)
|
|||
|
||||
/*
|
||||
* group_norm_util() returns the approximated group util relative to it's
|
||||
* current capacity (busy ratio) in the range [0..SCHED_LOAD_SCALE] for use in
|
||||
* energy calculations. Since task executions may or may not overlap in time in
|
||||
* the group the true normalized util is between max(cpu_norm_util(i)) and
|
||||
* sum(cpu_norm_util(i)) when iterating over all cpus in the group, i. The
|
||||
* latter is used as the estimate as it leads to a more pessimistic energy
|
||||
* current capacity (busy ratio), in the range [0..SCHED_LOAD_SCALE], for use
|
||||
* in energy calculations.
|
||||
*
|
||||
* Since task executions may or may not overlap in time in the group the true
|
||||
* normalized util is between MAX(cpu_norm_util(i)) and SUM(cpu_norm_util(i))
|
||||
* when iterating over all CPUs in the group.
|
||||
* The latter estimate is used as it leads to a more pessimistic energy
|
||||
* estimate (more busy).
|
||||
*/
|
||||
static unsigned
|
||||
long group_norm_util(struct energy_env *eenv, struct sched_group *sg)
|
||||
{
|
||||
int i, delta;
|
||||
unsigned long util_sum = 0;
|
||||
unsigned long capacity = sg->sge->cap_states[eenv->cap_idx].cap;
|
||||
unsigned long util, util_sum = 0;
|
||||
int cpu;
|
||||
|
||||
for_each_cpu(i, sched_group_cpus(sg)) {
|
||||
delta = calc_util_delta(eenv, i);
|
||||
util_sum += __cpu_norm_util(i, capacity, delta);
|
||||
for_each_cpu(cpu, sched_group_cpus(sg)) {
|
||||
util = cpu_util_wake(cpu, eenv->task);
|
||||
|
||||
/*
|
||||
* If we are looking at the target CPU specified by the eenv,
|
||||
* then we should add the (estimated) utilization of the task
|
||||
* assuming we will wake it up on that CPU.
|
||||
*/
|
||||
if (unlikely(cpu == eenv->trg_cpu))
|
||||
util += eenv->util_delta;
|
||||
|
||||
util_sum += __cpu_norm_util(util, capacity);
|
||||
}
|
||||
|
||||
if (util_sum > SCHED_CAPACITY_SCALE)
|
||||
return SCHED_CAPACITY_SCALE;
|
||||
return util_sum;
|
||||
return min_t(unsigned long, util_sum, SCHED_CAPACITY_SCALE);
|
||||
}
|
||||
|
||||
static int find_new_capacity(struct energy_env *eenv,
|
||||
|
@ -5575,6 +5586,8 @@ static inline bool cpu_in_sg(struct sched_group *sg, int cpu)
|
|||
return cpu != -1 && cpumask_test_cpu(cpu, sched_group_cpus(sg));
|
||||
}
|
||||
|
||||
static inline unsigned long task_util(struct task_struct *p);
|
||||
|
||||
/*
|
||||
* energy_diff(): Estimate the energy impact of changing the utilization
|
||||
* distribution. eenv specifies the change: utilisation amount, source, and
|
||||
|
@ -5590,11 +5603,13 @@ static inline int __energy_diff(struct energy_env *eenv)
|
|||
int diff, margin;
|
||||
|
||||
struct energy_env eenv_before = {
|
||||
.util_delta = 0,
|
||||
.util_delta = task_util(eenv->task),
|
||||
.src_cpu = eenv->src_cpu,
|
||||
.dst_cpu = eenv->dst_cpu,
|
||||
.trg_cpu = eenv->src_cpu,
|
||||
.nrg = { 0, 0, 0, 0},
|
||||
.cap = { 0, 0, 0 },
|
||||
.task = eenv->task,
|
||||
};
|
||||
|
||||
if (eenv->src_cpu == eenv->dst_cpu)
|
||||
|
@ -5972,8 +5987,6 @@ boosted_task_util(struct task_struct *task)
|
|||
return util + margin;
|
||||
}
|
||||
|
||||
static int cpu_util_wake(int cpu, struct task_struct *p);
|
||||
|
||||
static unsigned long capacity_spare_wake(int cpu, struct task_struct *p)
|
||||
{
|
||||
return capacity_orig_of(cpu) - cpu_util_wake(cpu, p);
|
||||
|
@ -6681,6 +6694,7 @@ static int select_energy_cpu_brute(struct task_struct *p, int prev_cpu, int sync
|
|||
.src_cpu = prev_cpu,
|
||||
.dst_cpu = target_cpu,
|
||||
.task = p,
|
||||
.trg_cpu = target_cpu,
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue