Re: [PATCH 3/3] sched/fair: Consider uclamp for "task fits capacity" checks

From: Valentin Schneider
Date: Thu Nov 21 2019 - 07:56:57 EST


On 21/11/2019 11:56, Quentin Perret wrote:
> On Wednesday 20 Nov 2019 at 17:55:33 (+0000), Valentin Schneider wrote:
>> +static inline
>> +unsigned long uclamp_task_util(struct task_struct *p, unsigned long util)
>
> This 'util' parameter is always task_util_est(p) right ? You might want
> to remove it.
>

I went with copying uclamp_rq_util()'s API, but you're right in that I don't
see what other value (than util_est) would make sense for this helper. If
there is no objections I'll kill the parameter for v2.

>> +{
>> + return clamp(util,
>> + (unsigned long)uclamp_eff_value(p, UCLAMP_MIN),
>> + (unsigned long)uclamp_eff_value(p, UCLAMP_MAX));
>> +}
>
> Thanks,
> Quentin
>

Another thing I realized overnight; tell me what you think:

> @@ -6274,6 +6274,15 @@ static int find_energy_efficient_cpu(struct task_struct *p, int prev_cpu)
> if (!fits_capacity(util, cpu_cap))
> continue;
>
> + /*
> + * Skip CPUs that don't satisfy uclamp requests. Note
> + * that the above already ensures the CPU has enough
> + * spare capacity for the task; this is only really for
> + * uclamp restrictions.
> + */
> + if (!task_fits_capacity(p, capacity_orig_of(cpu)))
> + continue;

This is partly redundant with the above, I think. What we really want here
is just

fits_capacity(uclamp_eff_value(p, UCLAMP_MIN), capacity_orig_of(cpu))

but this would require some inline #ifdeffery.

> +
> /* Always use prev_cpu as a candidate. */
> if (cpu == prev_cpu) {
> prev_delta = compute_energy(p, prev_cpu, pd);