mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christian Loehle <christian.loehle@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Linux PM <linux-pm@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Doug Smythies <dsmythies@telus.net>
Subject: Re: [PATCH v1 1/5] cpuidle: governors: teo: Avoid selecting states with zero-size bins
Date: Mon, 26 Jan 2026 12:05:28 +0000	[thread overview]
Message-ID: <02693dc9-e6f7-4683-8bba-4de5e8854689@arm.com> (raw)
In-Reply-To: <CAJZ5v0iygK59hvYKfNy0AYXe4Nyn-kM3dnY-9ongeGWc_jZ+3Q@mail.gmail.com>

On 1/26/26 11:40, Rafael J. Wysocki wrote:
> On Mon, Jan 26, 2026 at 10:18 AM Christian Loehle
> <christian.loehle@arm.com> wrote:
>>
>> On 1/23/26 20:46, Rafael J. Wysocki wrote:
>>> On Wed, Jan 21, 2026 at 2:10 PM Christian Loehle
>>> <christian.loehle@arm.com> wrote:
>>>>
>>>> On 1/14/26 19:44, Rafael J. Wysocki wrote:
>>>>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>>>
>>>>> If the last two enabled idle states have the same target residency which
>>>>> is at least equal to TICK_NSET, teo may select the next-to-last one even
>>>>
>>>> s/TICK_NSET/TICK_NSEC
>>>
>>> Yup, thanks!
>>>
>>>>> though the size of that state's bin is 0, which is confusing.
>>>>>
>>>>> Prevent that from happening by adding a target residency check to the
>>>>> relevant code path.
>>>>>
>>>>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>>>> ---
>>>>>  drivers/cpuidle/governors/teo.c |   10 ++++++++++
>>>>>  1 file changed, 10 insertions(+)
>>>>>
>>>>> --- a/drivers/cpuidle/governors/teo.c
>>>>> +++ b/drivers/cpuidle/governors/teo.c
>>>>> @@ -388,6 +388,15 @@ static int teo_select(struct cpuidle_dri
>>>>>                       while (min_idx < idx &&
>>>>>                              drv->states[min_idx].target_residency_ns < TICK_NSEC)
>>>>>                               min_idx++;
>>>>> +
>>>>> +                     /*
>>>>> +                      * Avoid selecting a state with a lower index, but with
>>>>> +                      * the same target residency as the current candidate
>>>>> +                      * one.
>>>>> +                      */
>>>>> +                     if (drv->states[min_idx].target_residency_ns ==
>>>>> +                                     drv->states[idx].target_residency_ns)
>>>>
>>>> We need to check that min_idx isn't disabled though, otherwise we now skip a
>>>> potential (enabled) idx==1 if min_idx==2 and min_idx is disabled.
>>>
>>> Not really because idx is the current candidate state and it is
>>> enabled.  We'll use idx if this check is true, not min_idx.
>>>
>>
>> Are you sure?
> 
> Yeah, pretty much.
> 
>> I meant initially:
>>
>>                 for (i = intercept_max_idx; i >= min_idx; i--) {
>>                         intercept_sum += cpu_data->state_bins[i].intercepts;
>>
>>                         if (dev->states_usage[i].disable)
>>                                 continue;
>>
>>                         idx = i;
>>                         if (2 * intercept_sum > idx_intercept_sum)
>>                                 break;
>>                 }
>> might skip an idx==3 if it enters with min_idx==2 (sorry, messed up the +-1 in the initial mail)
>> even though idx==3 might have the same residency as idx==2.
>> So if idx==2 is disabled we could've selected idx==3, but now won't and will go for idx==1 or
>> whatever is the next shallower enabled state.
> 
> But that's after patch [5/5] that has problems (I have a new version
> of it ready to send, will do that later today).
> 
> Look at the original 6.19-rc code and patch [1/1] by itself and you'll
> see what I mean.
> 
Duh you're right, sorry about the noise :/

  reply	other threads:[~2026-01-26 12:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-14 19:42 [PATCH v1 0/5] cpuidle: governors: teo: Wakeup events classification change and some refinements Rafael J. Wysocki
2026-01-14 19:44 ` [PATCH v1 1/5] cpuidle: governors: teo: Avoid selecting states with zero-size bins Rafael J. Wysocki
2026-01-21 13:09   ` Christian Loehle
2026-01-23 20:46     ` Rafael J. Wysocki
2026-01-26  9:18       ` Christian Loehle
2026-01-26 11:40         ` Rafael J. Wysocki
2026-01-26 12:05           ` Christian Loehle [this message]
2026-01-14 19:44 ` [PATCH v1 2/5] cpuidle: governors: teo: Avoid fake intercepts produced by tick Rafael J. Wysocki
2026-01-21 13:34   ` Christian Loehle
2026-01-14 19:45 ` [PATCH v1 3/5] cpuidle: governors: teo: Refine tick_intercepts vs total events check Rafael J. Wysocki
2026-01-21 13:36   ` Christian Loehle
2026-01-14 19:46 ` [PATCH v1 4/5] cpuidle: governors: teo: Adjust the classification of wakeup events Rafael J. Wysocki
2026-01-14 19:47 ` [PATCH v1 5/5] cpuidle: governors: teo: Refine intercepts-based idle state lookup Rafael J. Wysocki
2026-01-16 11:52 ` [PATCH v1 0/5] cpuidle: governors: teo: Wakeup events classification change and some refinements Christian Loehle
2026-01-16 12:29   ` Rafael J. Wysocki
2026-01-19  9:53     ` Christian Loehle
2026-01-19 12:09       ` Rafael J. Wysocki
2026-01-19 16:20         ` Doug Smythies
2026-01-20 15:29 ` [Update][PATCH v1.1 4/5] cpuidle: governors: teo: Adjust the classification of wakeup events Rafael J. Wysocki
2026-01-25 17:21   ` Doug Smythies
2026-01-25 19:38     ` Christian Loehle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02693dc9-e6f7-4683-8bba-4de5e8854689@arm.com \
    --to=christian.loehle@arm.com \
    --cc=dsmythies@telus.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®