Re: [RFC PATCH v4 4/6] sched/cpufreq: Introduce sugov_cpu_ramp_boost

From: Douglas Raillard
Date: Thu Feb 13 2020 - 05:49:13 EST




On 2/10/20 1:08 PM, Peter Zijlstra wrote:
> On Wed, Jan 22, 2020 at 05:35:36PM +0000, Douglas RAILLARD wrote:
>
>> +static unsigned long sugov_cpu_ramp_boost_update(struct sugov_cpu *sg_cpu)
>> +{
>> + struct rq *rq = cpu_rq(sg_cpu->cpu);
>> + unsigned long util_est_enqueued;
>> + unsigned long util_avg;
>> + unsigned long boost = 0;
>> +
>
> Should we NO-OP this function when !sched_feat(UTIL_EST) ?
>
>> + util_est_enqueued = READ_ONCE(rq->cfs.avg.util_est.enqueued);
>
> Otherwise you're reading garbage here, no?

Most likely indeed. The boosting should be disabled in that case.

>
>> + util_avg = READ_ONCE(rq->cfs.avg.util_avg);
>> +
>> + /*
>> + * Boost when util_avg becomes higher than the previous stable
>> + * knowledge of the enqueued tasks' set util, which is CPU's
>> + * util_est_enqueued.
>> + *
>> + * We try to spot changes in the workload itself, so we want to
>> + * avoid the noise of tasks being enqueued/dequeued. To do that,
>> + * we only trigger boosting when the "amount of work" enqueued
>> + * is stable.
>> + */
>> + if (util_est_enqueued == sg_cpu->util_est_enqueued &&
>> + util_avg >= sg_cpu->util_avg &&
>> + util_avg > util_est_enqueued)
>> + boost = util_avg - util_est_enqueued;
>> +
>> + sg_cpu->util_est_enqueued = util_est_enqueued;
>> + sg_cpu->util_avg = util_avg;
>> + WRITE_ONCE(sg_cpu->ramp_boost, boost);
>> + return boost;
>> +}