Re: [PATCH 1/2] cpufreq_schedutil: Refactor sugov_cpu_is_busy()

From: Christian Loehle
Date: Thu Jun 20 2024 - 05:40:57 EST


On 6/19/24 20:07, Tejun Heo wrote:
> On Wed, Jun 19, 2024 at 08:57:56AM -1000, Tejun Heo wrote:
>> Hello, Christian.
>>
>> On Wed, Jun 19, 2024 at 03:07:32PM +0100, Christian Loehle wrote:
>>>> + if (sugov_hold_freq(sg_cpu) && next_f < sg_policy->next_freq &&
>>>> !sg_policy->need_freq_update) {
>>>> next_f = sg_policy->next_freq;
>>>>
>>>
>>> Not necessarily related to your changes, but in case you're touching this
>>> again, maybe sugov_hold_freq() could be the last condition?
>>
>> I'll update the patch so that sugov_hold_freq() is the last condition.
>
> Oh, looking at the code again, this would lead to behavior change, right? It
> changes the period over which non-idleness is measured. Maybe that's okay
> but seems out-of-scope for a refactoring patch. I'll leave it as-is.

It does prevent idle_calls being updated in some cases, but see below I don't
think they are that deliberate anyway.

>
>>> And do we want something like
>>> #ifdef CONFIG_NO_HZ_COMMON
>>> else
>>> sg_cpu->saved_idle_calls = tick_nohz_get_idle_calls_cpu(sg_cpu->cpu);
>>> #endif
>>> here?
>>
>> I have no idea but if something like the above is necessary, it'd probably
>> fit better in the #else definition of sugof_hold_freq() or just move the
>> #ifdef inside the function body so that the common part is outside?
>
> and ->saved_idle_calls isn't even defined if !NO_HZ_COMMON and is only used
> to determine whether to hold frequency, so the above doesn't seem necessary
> either.

When reading that code again it seems like the right thing to do.
Anyway feel free to ignore, I might pick it up myself.
I'll think it through some more, the question mark was more like an open
question to anyone reading this.

Kind Regards,
Christian