Skip to content

Commit 425b753

Browse files
committed
cpuidle: teo: Rearrange idle state lookup code
Rearrange code in the idle state lookup loop in teo_select() to make it somewhat easier to follow and update comments around it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Tested-by: Aboorva Devarajan <[email protected]> Tested-by: Christian Loehle <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 5a597a1 commit 425b753

File tree

1 file changed

+20
-14
lines changed
  • drivers/cpuidle/governors

1 file changed

+20
-14
lines changed

drivers/cpuidle/governors/teo.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
367367
* If the sum of the intercepts metric for all of the idle states
368368
* shallower than the current candidate one (idx) is greater than the
369369
* sum of the intercepts and hits metrics for the candidate state and
370-
* all of the deeper states a shallower idle state is likely to be a
370+
* all of the deeper states, a shallower idle state is likely to be a
371371
* better choice.
372372
*/
373373
prev_intercept_idx = idx;
@@ -396,30 +396,36 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
396396
* first enabled state that is deep enough.
397397
*/
398398
if (teo_state_ok(i, drv) &&
399-
!dev->states_usage[i].disable)
399+
!dev->states_usage[i].disable) {
400400
idx = i;
401-
else
402-
idx = first_suitable_idx;
403-
401+
break;
402+
}
403+
idx = first_suitable_idx;
404404
break;
405405
}
406406

407407
if (dev->states_usage[i].disable)
408408
continue;
409409

410-
if (!teo_state_ok(i, drv)) {
410+
if (teo_state_ok(i, drv)) {
411411
/*
412-
* The current state is too shallow, but if an
413-
* alternative candidate state has been found,
414-
* it may still turn out to be a better choice.
412+
* The current state is deep enough, but still
413+
* there may be a better one.
415414
*/
416-
if (first_suitable_idx != idx)
417-
continue;
418-
419-
break;
415+
first_suitable_idx = i;
416+
continue;
420417
}
421418

422-
first_suitable_idx = i;
419+
/*
420+
* The current state is too shallow, so if no suitable
421+
* states other than the initial candidate have been
422+
* found, give up (the remaining states to check are
423+
* shallower still), but otherwise the first suitable
424+
* state other than the initial candidate may turn out
425+
* to be preferable.
426+
*/
427+
if (first_suitable_idx == idx)
428+
break;
423429
}
424430
}
425431
if (!idx && prev_intercept_idx) {

0 commit comments

Comments
 (0)