Skip to content

Commit 61320d2

Browse files
rafaeljwrekanorman
authored andcommitted
UPSTREAM: cpuidle: teo: Skip sleep length computation for low latency constraints
If the idle state exit latency constraint is sufficiently low, it is better to avoid the additional latency related to calling tick_nohz_get_sleep_length(). It is also not necessary to compute the sleep length in that case because shallow idle state selection will be forced then regardless of the recent wakeup history. Accordingly, skip the sleep length computation and subsequent checks of the exit latency constraint is low enough. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Christian Loehle <christian.loehle@arm.com> Link: https://patch.msgid.link/6122398.lOV4Wx5bFT@rjwysocki.net (cherry picked from commit 16c8d75) Bug: 450671466 Change-Id: I476f47dee40bd1aeb04251071df9ed25c0790aa2 Signed-off-by: Reka Norman <rekanorman@google.com>
1 parent 604eefc commit 61320d2

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

  • drivers/cpuidle/governors

drivers/cpuidle/governors/teo.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105

106106
#include "gov.h"
107107

108+
/*
109+
* Idle state exit latency threshold used for deciding whether or not to check
110+
* the time till the closest expected timer event.
111+
*/
112+
#define LATENCY_THRESHOLD_NS (RESIDENCY_THRESHOLD_NS / 2)
113+
108114
/*
109115
* The PULSE value is added to metrics when they grow and the DECAY_SHIFT value
110116
* is used for decreasing metrics on a regular basis.
@@ -432,9 +438,14 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
432438
* duration falls into that range in the majority of cases, assume
433439
* non-timer wakeups to be dominant and skip updating the sleep length
434440
* to reduce latency.
441+
*
442+
* Also, if the latency constraint is sufficiently low, it will force
443+
* shallow idle states regardless of the wakeup type, so the sleep
444+
* length need not be known in that case.
435445
*/
436446
if ((!idx || drv->states[idx].target_residency_ns < RESIDENCY_THRESHOLD_NS) &&
437-
2 * cpu_data->short_idles >= cpu_data->total)
447+
(2 * cpu_data->short_idles >= cpu_data->total ||
448+
latency_req < LATENCY_THRESHOLD_NS))
438449
goto out_tick;
439450

440451
duration_ns = tick_nohz_get_sleep_length(&delta_tick);

0 commit comments

Comments
 (0)