[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ccf56821-6553-4bcc-8f87-1367fe27d734@arm.com>
Date: Mon, 10 Nov 2025 07:58:11 +0000
From: Christian Loehle <christian.loehle@....com>
To: "Rafael J. Wysocki" <rafael@...nel.org>,
Linux PM <linux-pm@...r.kernel.org>,
Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>
Subject: Re: [PATCH v2] cpuidle: Add sanity check for exit latency and target
residency
On 11/7/25 19:07, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@...el.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@....com>
> cpuidle assumptions.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.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)
>
>
>
>
Powered by blists - more mailing lists