Skip to content

Commit b9a6af2

Browse files
committed
cpuidle: teo: Drop local variable prev_intercept_idx
Local variable prev_intercept_idx in teo_select() is redundant because it cannot be 0 when candidate state index is 0. The prev_intercept_idx value is the index of the deepest enabled idle state, so if it is 0, state 0 is the deepest enabled idle state, in which case it must be the only enabled idle state, but then teo_select() would have returned early before initializing prev_intercept_idx. Thus prev_intercept_idx must be nonzero and the check of it against 0 always passes, so it can be dropped altogether. 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] [ rjw: Fixed typo in the changelog ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent ea18540 commit b9a6af2

File tree

1 file changed

+5
-10
lines changed
  • drivers/cpuidle/governors

1 file changed

+5
-10
lines changed

drivers/cpuidle/governors/teo.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
292292
unsigned int hit_sum = 0;
293293
int constraint_idx = 0;
294294
int idx0 = 0, idx = -1;
295-
int prev_intercept_idx;
296295
s64 duration_ns;
297296
int i;
298297

@@ -370,7 +369,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
370369
* all of the deeper states, a shallower idle state is likely to be a
371370
* better choice.
372371
*/
373-
prev_intercept_idx = idx;
374372
if (2 * idx_intercept_sum > cpu_data->total - idx_hit_sum) {
375373
int first_suitable_idx = idx;
376374

@@ -437,14 +435,11 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
437435
idx = constraint_idx;
438436

439437
if (!idx) {
440-
if (prev_intercept_idx) {
441-
/*
442-
* Query the sleep length to be able to count the wakeup
443-
* as a hit if it is caused by a timer.
444-
*/
445-
duration_ns = tick_nohz_get_sleep_length(&delta_tick);
446-
cpu_data->sleep_length_ns = duration_ns;
447-
}
438+
/*
439+
* Query the sleep length to be able to count the wakeup as a
440+
* hit if it is caused by a timer.
441+
*/
442+
cpu_data->sleep_length_ns = tick_nohz_get_sleep_length(&delta_tick);
448443
goto out_tick;
449444
}
450445

0 commit comments

Comments
 (0)