Re: [PATCH v2 2/2] sched/fair, cpufreq: Introduce 'runnable boosting'

From: Peter Zijlstra
Date: Fri May 12 2023 - 07:22:49 EST


On Fri, May 12, 2023 at 12:10:29PM +0200, Dietmar Eggemann wrote:

> -static unsigned long cpu_util(int cpu, struct task_struct *p, int dst_cpu)
> +static unsigned long
> +cpu_util(int cpu, struct task_struct *p, int dst_cpu, int boost)
> {
> struct cfs_rq *cfs_rq = &cpu_rq(cpu)->cfs;
> unsigned long util = READ_ONCE(cfs_rq->avg.util_avg);
> + unsigned long runnable;
> +
> + runnable = boost ? READ_ONCE(cfs_rq->avg.runnable_avg) : 0;
> + util = max(util, runnable);
>
if (boost)
util = max(util, READ_ONCE(cfs_rq->avg.runnable_avg));


> @@ -7239,9 +7246,9 @@ static unsigned long cpu_util(int cpu, struct task_struct *p, int dst_cpu)
> *
> * Return: (Estimated) utilization for the specified CPU.
> */

Given that cpu_util() is the base function should this comment move
there?

> -unsigned long cpu_util_cfs(int cpu)
> +unsigned long cpu_util_cfs(int cpu, int boost)
> {
> - return cpu_util(cpu, NULL, -1);
> + return cpu_util(cpu, NULL, -1, boost);
> }

AFAICT the @boost argument is always a constant (0 or 1). Would it not
make more sense to simply add:

unsigned long cpu_util_cfs_boost(int cpu)
{
return cpu_util(cpu, NULL, -1, 1);
}

and use that in the few sites that actually need it?