summaryrefslogtreecommitdiffstats
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-08-21 04:44:10 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-08-25 07:16:08 -0400
commit757ab15c3f4968b5a29caf3fe8b67660ce84c3cd (patch)
tree0f42fe2012bec1b64dc4fbdf8aae306e3268c944 /drivers/cpuidle
parentdfec4a8478e8e81483a94b663f13153bb7796800 (diff)
cpuidle: menu: Retain tick when shallow state is selected
The case addressed by commit 5ef499cd571c (cpuidle: menu: Handle stopped tick more aggressively) in the stopped tick case is present when the tick has not been stopped yet too. Namely, if only two CPU idle states, shallow state A with target residency significantly below the tick boundary and deep state B with target residency significantly above it, are available and the predicted idle duration is above the tick boundary, but below the target residency of state B, state A will be selected and the CPU may spend indefinite amount of time in it, which is not quite energy-efficient. However, if the tick has not been stopped yet and the governor is about to select a shallow idle state for the CPU even though the idle duration predicted by it is above the tick boundary, it should be fine to wake up the CPU early, so the tick can be retained then and the governor will have a chance to select a deeper state when it runs next time. [Note that when this really happens, it will make the idle duration predictor believe that the CPU might be idle longer than predicted, which will make it more likely to predict longer idle durations going forward, but that will also cause deeper idle states to be selected going forward, on average, which is what's needed here.] Fixes: 87c9fe6ee495 (cpuidle: menu: Avoid selecting shallow states with stopped tick) Reported-by: Leo Yan <leo.yan@linaro.org> Cc: 4.17+ <stable@vger.kernel.org> # 4.17+: 5ef499cd571c (cpuidle: menu: Handle ...) Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/governors/menu.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 110483f0e3fb..e26a40971b26 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -379,9 +379,20 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
379 if (idx == -1) 379 if (idx == -1)
380 idx = i; /* first enabled state */ 380 idx = i; /* first enabled state */
381 if (s->target_residency > data->predicted_us) { 381 if (s->target_residency > data->predicted_us) {
382 if (!tick_nohz_tick_stopped()) 382 if (data->predicted_us < TICK_USEC)
383 break; 383 break;
384 384
385 if (!tick_nohz_tick_stopped()) {
386 /*
387 * If the state selected so far is shallow,
388 * waking up early won't hurt, so retain the
389 * tick in that case and let the governor run
390 * again in the next iteration of the loop.
391 */
392 expected_interval = drv->states[idx].target_residency;
393 break;
394 }
395
385 /* 396 /*
386 * If the state selected so far is shallow and this 397 * If the state selected so far is shallow and this
387 * state's target residency matches the time till the 398 * state's target residency matches the time till the