Re: [PATCH v3 2/2] cpufreq: add virtual-cpufreq driver

From: Quentin Perret
Date: Tue Aug 01 2023 - 05:47:20 EST


Hi David,

On Monday 31 Jul 2023 at 10:46:09 (-0700), David Dai wrote:
> +static unsigned int virt_cpufreq_set_perf(struct cpufreq_policy *policy)
> +{
> + struct virt_cpufreq_drv_data *data = policy->driver_data;
> + /*
> + * Use cached frequency to avoid rounding to freq table entries
> + * and undo 25% frequency boost applied by schedutil.
> + */

The VMM would be a better place for this scaling I think, the driver
can't/shouldn't make assumptions about the governor it is running with
given that this is a guest userspace decision essentially.

IIRC the fast_switch() path is only used by schedutil, so one could
probably make a case to scale things there, but it'd be inconsistent
with the "slow" switch case, and would create a fragile dependency, so
it's probably not worth pursuing.

> + u32 freq = mult_frac(policy->cached_target_freq, 80, 100);
> +
> + data->ops->set_freq(policy, freq);
> + return 0;
> +}

Thanks,
Quentin