Re: [RFC PATCH v5 0/2] cpuidle: teo: Introduce util-awareness

From: Rafael J. Wysocki
Date: Tue Jan 03 2023 - 12:12:35 EST


On Tue, Jan 3, 2023 at 3:22 PM Kajetan Puchalski
<kajetan.puchalski@xxxxxxx> wrote:
>
> On Wed, Nov 30, 2022 at 03:32:02PM +0000, Kajetan Puchalski wrote:
>
> Hi Rafael,
>
> As it's been a while since the last email I wanted to bump this thread
> and ask what you think about the last changes.

Right, I'll send my comments on the last version of the patch separately.

> Additionally, I got some emails from the kernel test robot and noticed
> that sched_cpu_util is contingent on CONFIG_SMP so in the current form
> there's build errors on !SMP machines.
>
> The following change should fix the problem, do you think it's all right to add?
>
> @@ -207,10 +207,17 @@ static DEFINE_PER_CPU(struct teo_cpu, teo_cpus);
> * @dev: Target CPU
> * @cpu_data: Governor CPU data for the target CPU
> */
> +#ifdef CONFIG_SMP
> static void teo_get_util(struct cpuidle_device *dev, struct teo_cpu *cpu_data)
> {
> cpu_data->utilized = sched_cpu_util(dev->cpu) > cpu_data->util_threshold;
> }
> +#else
> +static void teo_get_util(struct cpuidle_device *dev, struct teo_cpu *cpu_data)
> +{
> + cpu_data->utilized = false;
> +}
> +#endif
>

IMV it would be better to use teo_cpu_is_utilized() that would be
called to update cpu_data->utilized this way

cpu_data->utilized = teo_cpu_is_utilized(dev->cpu, cpu_data->util_threshold);

and define it as an empty stab in the !SMP case.