Re: [RFC PATCH v3 07/10] sched/fair: Introduce an energy estimation helper function

From: Juri Lelli
Date: Fri Jun 08 2018 - 06:31:04 EST


On 21/05/18 15:25, Quentin Perret wrote:

[...]

> +static long compute_energy(struct task_struct *p, int dst_cpu)
> +{
> + long util, max_util, sum_util, energy = 0;
> + struct sched_energy_fd *sfd;
> + int cpu;
> +
> + for_each_freq_domain(sfd) {
> + max_util = sum_util = 0;
> + for_each_cpu_and(cpu, freq_domain_span(sfd), cpu_online_mask) {
> + util = cpu_util_next(cpu, p, dst_cpu);
> + util += cpu_util_dl(cpu_rq(cpu));
> + /* XXX: add RT util_avg when available. */

em_fd_energy() below uses this to know which power to pick in the freq
table. So, if you have any RT task running on cpu freq will be at max
anyway. It seems to me that in this case max_util for the freq_domain
must be max_freq (w/o considering rt.util_avg as schedutil does). Then
you could probably still use rt.util_avg to get the percentage of busy
time with sum_util?

> +
> + max_util = max(util, max_util);
> + sum_util += util;
> + }
> +
> + energy += em_fd_energy(sfd->fd, max_util, sum_util);
> + }
> +
> + return energy;
> +}

Best,

- Juri