[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <5939579.DvuYhMxLoT@rafael.j.wysocki>
Date: Fri, 07 Nov 2025 19:19:21 +0100
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Linux PM <linux-pm@...r.kernel.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Daniel Lezcano <daniel.lezcano@...aro.org>,
Artem Bityutskiy <artem.bityutskiy@...ux.intel.com>
Subject:
[PATCH v1] cpuidle: Add sanity check for exit latency and target residency
From: Rafael J. Wysocki <rafael.j.wysocki@...el.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@...el.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;
+ }
}
}
Powered by blists - more mailing lists