mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cpuidle: teo: fix underflow of recent intercepts
@ 2024-05-19 21:03 Christian Loehle
  2024-05-20  9:59 ` Christian Loehle
  2024-05-20 14:30 ` Christian Loehle
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Loehle @ 2024-05-19 21:03 UTC (permalink / raw)
  To: linux-kernel, linux-pm, Rafael J. Wysocki, Daniel Lezcano
  Cc: Qais Yousef, kajetan.puchalski, Anna-Maria Behnsen

The recent counter of each cpuidle state bin reflects the number of
recent intercepts. It's decremented and incremented accordingly.
The decrement was never checked for 0, therefore underflowing into a
value teo cannot easily recover from.

The underflow lead to deeper idle states being skipped because teo
assumed interception was likely and it preferring shallower states.

Fixes: 77577558f25d ("cpuidle: teo: Rework most recent idle duration values treatment")
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
 drivers/cpuidle/governors/teo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index 7244f71c59c5..42fb2771e35d 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -290,7 +290,8 @@ static void teo_update(struct cpuidle_driver *drv, struct cpuidle_device *dev)
 	if (cpu_data->next_recent_idx >= NR_RECENT)
 		cpu_data->next_recent_idx = 0;
 
-	if (cpu_data->recent_idx[i] >= 0)
+	if (cpu_data->recent_idx[i] >= 0 &&
+			cpu_data->state_bins[cpu_data->recent_idx[i]].recent)
 		cpu_data->state_bins[cpu_data->recent_idx[i]].recent--;
 
 	/*
-- 
2.34.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-20 14:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-19 21:03 [PATCH] cpuidle: teo: fix underflow of recent intercepts Christian Loehle
2024-05-20  9:59 ` Christian Loehle
2024-05-20 14:30 ` Christian Loehle

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®