diff mbox series

[v1,4/4] cpuidle: teo: Combine candidate state index checks against 0

Message ID 2296767.iZASKD2KPV@rjwysocki.net
State New
Headers show
Series cpuidle: teo: Fix and cleanups | expand

Commit Message

Rafael J. Wysocki Jan. 10, 2025, 12:56 p.m. UTC
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

There are two candidate state index checks against 0 in teo_select()
that need not be separate, so combine them and update comments around
them.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/cpuidle/governors/teo.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
diff mbox series

Patch

--- a/drivers/cpuidle/governors/teo.c
+++ b/drivers/cpuidle/governors/teo.c
@@ -436,25 +436,25 @@ 
 	if (idx > constraint_idx)
 		idx = constraint_idx;
 
-	if (!idx && prev_intercept_idx &&
-	    !(drv->states[0].flags & CPUIDLE_FLAG_POLLING)) {
+
+	if (!idx) {
 		/*
-		 * We have to query the sleep length here otherwise we don't
-		 * know after wakeup if our guess was correct.
+		 * Skip the timers check if state 0 is the current candidate
+		 * one because an immediate non-timer wakeup is expected then.
 		 */
-		duration_ns = tick_nohz_get_sleep_length(&delta_tick);
-		cpu_data->sleep_length_ns = duration_ns;
+		if (prev_intercept_idx &&
+		    !(drv->states[0].flags & CPUIDLE_FLAG_POLLING)) {
+			/*
+			 * Query the sleep length to be able to count the wakeup
+			 * as a hit if it is caused by a timer.
+			 */
+			duration_ns = tick_nohz_get_sleep_length(&delta_tick);
+			cpu_data->sleep_length_ns = duration_ns;
+		}
 		goto out_tick;
 	}
 
 	/*
-	 * Skip the timers check if state 0 is the current candidate one,
-	 * because an immediate non-timer wakeup is expected in that case.
-	 */
-	if (!idx)
-		goto out_tick;
-
-	/*
 	 * If state 0 is a polling one, check if the target residency of
 	 * the current candidate state is low enough and skip the timers
 	 * check in that case too.