summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-01-14 22:44:04 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2026-01-23 23:49:54 +0300
commit4bd2221f231d798b01027367857d9ba2f24f6ea0 (patch)
tree23b09523132dcd70112f5cebdbab776f3d3d9e04
parent80606f4eb8d7484ab7f7d6f0fd30d71e6fbcf328 (diff)
downloadlinux-4bd2221f231d798b01027367857d9ba2f24f6ea0.tar.xz
cpuidle: governors: teo: Avoid selecting states with zero-size bins
If the last two enabled idle states have the same target residency which is at least equal to TICK_NSEC, teo may select the next-to-last one even though the size of that state's bin is 0, which is confusing. Prevent that from happening by adding a target residency check to the relevant code path. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Christian Loehle <christian.loehle@arm.com> [ rjw: Fixed a typo in the changelog ] Link: https://patch.msgid.link/3033265.e9J7NaK4W3@rafael.j.wysocki Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/cpuidle/governors/teo.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c
index 81ac5fd58a1c..9820ef36a664 100644
--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -388,6 +388,15 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
while (min_idx < idx &&
drv->states[min_idx].target_residency_ns < TICK_NSEC)
min_idx++;
+
+ /*
+ * Avoid selecting a state with a lower index, but with
+ * the same target residency as the current candidate
+ * one.
+ */
+ if (drv->states[min_idx].target_residency_ns ==
+ drv->states[idx].target_residency_ns)
+ goto constraint;
}
/*
@@ -410,6 +419,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
}
}
+constraint:
/*
* If there is a latency constraint, it may be necessary to select an
* idle state shallower than the current candidate one.