Skip to content

Commit 4bd2221

Browse files
committed
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>
1 parent 80606f4 commit 4bd2221

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

  • drivers/cpuidle/governors

drivers/cpuidle/governors/teo.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,15 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
388388
while (min_idx < idx &&
389389
drv->states[min_idx].target_residency_ns < TICK_NSEC)
390390
min_idx++;
391+
392+
/*
393+
* Avoid selecting a state with a lower index, but with
394+
* the same target residency as the current candidate
395+
* one.
396+
*/
397+
if (drv->states[min_idx].target_residency_ns ==
398+
drv->states[idx].target_residency_ns)
399+
goto constraint;
391400
}
392401

393402
/*
@@ -410,6 +419,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
410419
}
411420
}
412421

422+
constraint:
413423
/*
414424
* If there is a latency constraint, it may be necessary to select an
415425
* idle state shallower than the current candidate one.

0 commit comments

Comments
 (0)