Linux Power Management development
 help / color / mirror / Atom feed
From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
	Linux PM <linux-pm@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: Re: [PATCH v1] cpuidle: Add sanity check for exit latency and target residency
Date: Fri, 07 Nov 2025 20:47:20 +0200	[thread overview]
Message-ID: <a8d3fe252f5ed9d513c026331eeabfe5971196b1.camel@linux.intel.com> (raw)
In-Reply-To: <5939579.DvuYhMxLoT@rafael.j.wysocki>

On Fri, 2025-11-07 at 19:19 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> 
> Make __cpuidle_driver_init() sanitize CPU idle states so that the exit
> latency of a given state is not greater than its target residency which
> would break cpuidle assumptions.
> 
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>  drivers/cpuidle/driver.c |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> --- a/drivers/cpuidle/driver.c
> +++ b/drivers/cpuidle/driver.c
> @@ -193,6 +193,16 @@ static void __cpuidle_driver_init(struct
>  			s->exit_latency_ns =  0;
>  		else
>  			s->exit_latency = div_u64(s->exit_latency_ns, NSEC_PER_USEC);
> +
> +		/*
> +		 * Ensure that the exit latency of a CPU idle state does not
> +		 * exceed its target residency which is assumed in cpuidle in
> +		 * multiple places.
> +		 */
> +		if (s->exit_latency_ns > s->target_residency_ns) {
> +			s->target_residency_ns = s->exit_latency_ns;
> +			s->target_residency = s->exit_latency;
> +		}

I suggest to error out instead of capping it. Because as soon as you
cap it, you may end up with the target residency of the next C-state. 


Just erroring out is very explicit, no surprises, and the table
provider will have to just fix the table.


Thanks, Artem.


  reply	other threads:[~2025-11-07 18:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07 18:19 [PATCH v1] cpuidle: Add sanity check for exit latency and target residency Rafael J. Wysocki
2025-11-07 18:47 ` Artem Bityutskiy [this message]
2025-11-07 18:58   ` Rafael J. Wysocki

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=a8d3fe252f5ed9d513c026331eeabfe5971196b1.camel@linux.intel.com \
    --to=artem.bityutskiy@linux.intel.com \
    --cc=daniel.lezcano@linaro.org \
    --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