From: Christian Loehle <christian.loehle@arm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>,
Linux PM <linux-pm@vger.kernel.org>,
Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>
Subject: Re: [PATCH v2] cpuidle: Add sanity check for exit latency and target residency
Date: Mon, 10 Nov 2025 07:58:11 +0000 [thread overview]
Message-ID: <ccf56821-6553-4bcc-8f87-1367fe27d734@arm.com> (raw)
In-Reply-To: <12779486.O9o76ZdvQC@rafael.j.wysocki>
On 11/7/25 19:07, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Make __cpuidle_driver_init() fail if the exit latency of one of the
> driver's idle states is less than its exit latency which would break
s/exit latency/target residency/
for the second one here.
Apart from that
Reviewed-by: Christian Loehle <christian.loehle@arm.com>
> cpuidle assumptions.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
> v1 -> v2: Make __cpuidle_driver_init() fail if the check is not passed (Artem).
>
> ---
> drivers/cpuidle/driver.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> --- a/drivers/cpuidle/driver.c
> +++ b/drivers/cpuidle/driver.c
> @@ -152,7 +152,7 @@ static void cpuidle_setup_broadcast_time
> * __cpuidle_driver_init - initialize the driver's internal data
> * @drv: a valid pointer to a struct cpuidle_driver
> */
> -static void __cpuidle_driver_init(struct cpuidle_driver *drv)
> +static int __cpuidle_driver_init(struct cpuidle_driver *drv)
> {
> int i;
>
> @@ -193,7 +193,17 @@ 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)
> + return -EINVAL;
> }
> +
> + return 0;
> }
>
> /**
> @@ -223,7 +233,9 @@ static int __cpuidle_register_driver(str
> if (cpuidle_disabled())
> return -ENODEV;
>
> - __cpuidle_driver_init(drv);
> + ret = __cpuidle_driver_init(drv);
> + if (ret)
> + return ret;
>
> ret = __cpuidle_set_driver(drv);
> if (ret)
>
>
>
>
prev parent reply other threads:[~2025-11-10 7:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 19:07 Rafael J. Wysocki
2025-11-08 8:49 ` Artem Bityutskiy
2025-11-08 11:02 ` Rafael J. Wysocki
2025-11-08 11:48 ` Rafael J. Wysocki
2025-11-08 14:07 ` Artem Bityutskiy
2025-11-10 7:58 ` Christian Loehle [this message]
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=ccf56821-6553-4bcc-8f87-1367fe27d734@arm.com \
--to=christian.loehle@arm.com \
--cc=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
all inboxes | Powered by JetHome®