Re: [Question] About unnecessary policy_has_boost_freq() calls in freq_table.c

From: Rafael J. Wysocki

Date: Tue Sep 23 2025 - 08:46:54 EST


Hi,

On Tue, Sep 23, 2025 at 10:53 AM Zihuan Zhang <zhangzihuan@xxxxxxxxxx> wrote:
>
> Hi all,
>
> While reviewing the cpufreq code, I noticed that in
> cpufreq_table_validate_and_sort() the function policy_has_boost_freq()
> is still being called, even though most cpufreq drivers do not make use
> of the CPUFREQ_BOOST_FREQ flag.
>
> code in cpufreq_table_validate_and_sort():
>
> /* Driver's may have set this field already */
> if (policy_has_boost_freq(policy))
> policy->boost_supported = true;
>
>
> For drivers like acpi-cpufreq that don’t rely on CPUFREQ_BOOST_FREQ
> flag, this extra check looks confusing and possibly unnecessary.
>
> Would it make sense to move this check into cpufreq_boost_set_sw()
> instead, so that the call is only made when boost is actually relevant?

First off, setting policy->boost_supported doesn't really belong to
cpufreq_table_validate_and_sort(), so the idea of splitting it off
that function sounds reasonable to me.

However, cpufreq_boost_set_sw() is used as a .set_boost() callback, so
it gets called every time the "boost enabled" setting is changed. It
doesn't look like a good place for updating policy->boost_supported to
me.