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

From: Peter Zijlstra
Date: Sat May 13 2023 - 05:33:13 EST


On Fri, May 12, 2023 at 04:39:51PM +0200, Dietmar Eggemann wrote:
> On 12/05/2023 13:22, Peter Zijlstra wrote:
> > 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));
>
> I need the util_est = max(util_est, runnable) further down as well. Just
> want to fetch runnable only once.

Ah, fair enought; but still, please use a regular if().