From: Christian Loehle <christian.loehle@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Doug Smythies <dsmythies@telus.net>,
Aboorva Devarajan <aboorvad@linux.ibm.com>,
"Ionut Nechita (Sunlight Linux)" <sunlightlinux@gmail.com>
Subject: Re: [PATCH v2 1/2] cpuidle: governors: menu: Refine stopped tick handling
Date: Thu, 5 Mar 2026 10:45:05 +0000 [thread overview]
Message-ID: <ecbe0643-ce7f-4e67-a07c-01d8e6fc758c@arm.com> (raw)
In-Reply-To: <3341782.5fSG56mABF@rafael.j.wysocki>
On 2/23/26 15:38, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> This change is based on the observation that it is not in fact necessary
> to select a deep idle state every time the scheduler tick has been
> stopped before the idle state selection takes place. Namely, if the
> time till the closest timer (that is not the tick) is short enough,
> a shallow idle state can be selected because the timer will kick the
> CPU out of that state, so the damage from a possible overly optimistic
> selection will be limited.
>
> Update the menu governor in accordance with the above and use twice
> the tick period length as the "safe timer range" for allowing the
> original predicted_ns value to be used even if the tick has been
> stopped.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
> v1 -> v2: No changes
>
> ---
> drivers/cpuidle/governors/gov.h | 5 +++++
> drivers/cpuidle/governors/menu.c | 15 +++++++++------
> 2 files changed, 14 insertions(+), 6 deletions(-)
>
> --- a/drivers/cpuidle/governors/gov.h
> +++ b/drivers/cpuidle/governors/gov.h
> @@ -10,5 +10,10 @@
> * check the time till the closest expected timer event.
> */
> #define RESIDENCY_THRESHOLD_NS (15 * NSEC_PER_USEC)
> +/*
> + * If the closest timer is in this range, the governor idle state selection need
> + * not be adjusted after the scheduler tick has been stopped.
> + */
> +#define SAFE_TIMER_RANGE_NS (2 * TICK_NSEC)
>
> #endif /* __CPUIDLE_GOVERNOR_H */
> --- a/drivers/cpuidle/governors/menu.c
> +++ b/drivers/cpuidle/governors/menu.c
> @@ -261,13 +261,16 @@ static int menu_select(struct cpuidle_dr
> predicted_ns = min((u64)timer_us * NSEC_PER_USEC, predicted_ns);
> /*
> * If the tick is already stopped, the cost of possible short
> - * idle duration misprediction is much higher, because the CPU
> - * may be stuck in a shallow idle state for a long time as a
> - * result of it. In that case, say we might mispredict and use
> - * the known time till the closest timer event for the idle
> - * state selection.
> + * idle duration misprediction is higher because the CPU may get
> + * stuck in a shallow idle state then. To avoid that, if
> + * predicted_ns is small enough, say it might be mispredicted
> + * and use the known time till the closest timer for idle state
> + * selection unless that timer is going to trigger within
> + * SAFE_TIMER_RANGE_NS in which case it can be regarded as a
> + * sufficient safety net.
> */
> - if (tick_nohz_tick_stopped() && predicted_ns < TICK_NSEC)
> + if (tick_nohz_tick_stopped() && predicted_ns < TICK_NSEC &&
> + data->next_timer_ns > SAFE_TIMER_RANGE_NS)
> predicted_ns = data->next_timer_ns;
> } else {
> /*
>
>
>
So FWIW both patches look sane to me, I'm still trying to get some test setup
to see what this looks like and should look like, but for now:
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
next prev parent reply other threads:[~2026-03-05 10:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 15:37 [PATCH v2 0/2] cpuidle: governor: Modify the handling of stopped tick Rafael J. Wysocki
2026-02-23 15:38 ` [PATCH v2 1/2] cpuidle: governors: menu: Refine stopped tick handling Rafael J. Wysocki
2026-03-05 10:45 ` Christian Loehle [this message]
2026-04-03 17:07 ` Ionut Nechita (Wind River)
2026-02-23 15:40 ` [PATCH v2 2/2] cpuidle: governors: teo: Rearrange " Rafael J. Wysocki
2026-03-05 10:45 ` 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=ecbe0643-ce7f-4e67-a07c-01d8e6fc758c@arm.com \
--to=christian.loehle@arm.com \
--cc=aboorvad@linux.ibm.com \
--cc=dsmythies@telus.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sunlightlinux@gmail.com \
/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