Skip to content

Commit d557640

Browse files
committed
sched: idle: Make skipping governor callbacks more consistent
If the cpuidle governor .select() callback is skipped because there is only one idle state in the cpuidle driver, the .reflect() callback should be skipped as well, at least for consistency (if not for correctness), so do it. Fixes: e5c9ffc ("cpuidle: Skip governor when only one idle state is available") Signed-off-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Christian Loehle <[email protected]> Reviewed-by: Aboorva Devarajan <[email protected]> Reviewed-by: Frederic Weisbecker <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 1f318b9 commit d557640

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

drivers/cpuidle/cpuidle.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,6 @@ noinstr int cpuidle_enter_state(struct cpuidle_device *dev,
359359
int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
360360
bool *stop_tick)
361361
{
362-
/*
363-
* If there is only a single idle state (or none), there is nothing
364-
* meaningful for the governor to choose. Skip the governor and
365-
* always use state 0 with the tick running.
366-
*/
367-
if (drv->state_count <= 1) {
368-
*stop_tick = false;
369-
return 0;
370-
}
371-
372362
return cpuidle_curr_governor->select(drv, dev, stop_tick);
373363
}
374364

kernel/sched/idle.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static void cpuidle_idle_call(void)
221221

222222
next_state = cpuidle_find_deepest_state(drv, dev, max_latency_ns);
223223
call_cpuidle(drv, dev, next_state);
224-
} else {
224+
} else if (drv->state_count > 1) {
225225
bool stop_tick = true;
226226

227227
/*
@@ -239,6 +239,15 @@ static void cpuidle_idle_call(void)
239239
* Give the governor an opportunity to reflect on the outcome
240240
*/
241241
cpuidle_reflect(dev, entered_state);
242+
} else {
243+
tick_nohz_idle_retain_tick();
244+
245+
/*
246+
* If there is only a single idle state (or none), there is
247+
* nothing meaningful for the governor to choose. Skip the
248+
* governor and always use state 0.
249+
*/
250+
call_cpuidle(drv, dev, 0);
242251
}
243252

244253
exit_idle:

0 commit comments

Comments
 (0)