Re: [PATCH v3 1/2] arch_topology: seed capacity_freq_ref with highest available frequency
From: Ananthu C V
Date: Wed Nov 11 2026 - 07:18:43 EST
Hi Zhongqiu,
On Sun, Oct 11, 2026 at 10:16:37PM +0800, Zhongqiu Han wrote:
> The current implementation looks correct and works well. That said, we
> might be able to optimize it with a simpler implementation as shown
> below:
>
> +/**
> + * cpufreq_frequency_table_max - Get the highest frequency in a policy's
> table
> + * @policy: the &struct cpufreq_policy to inspect
> + *
> + * Boost entries (%CPUFREQ_BOOST_FREQ) are taken into account regardless of
> + * whether or not boost is currently enabled.
> + *
> + * Return: the highest valid frequency in @policy->freq_table, or 0 if
> there
> + * is no frequency table.
> + */
> +static inline unsigned int
> +cpufreq_frequency_table_max(const struct cpufreq_policy *policy)
> +{
> + struct cpufreq_frequency_table *pos;
> + unsigned int max_freq = 0;
> +
> + if (!policy->freq_table)
> + return 0;
> +
> + cpufreq_for_each_valid_entry(pos, policy->freq_table)
> + max_freq = max(max_freq, pos->frequency);
> +
> + return max_freq;
> +}
> +
>
>
> > static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy *policy)
> > {
> > struct cpufreq_frequency_table *pos;
ack, I will try to further simply this with taking in your suggestions, thanks.
> Thx and BRs,
> Zhongqiu Han
Best,
Ananthu