Skip to content

Commit 094a7c3

Browse files
committed
Merge branch 'pm-cpuidle'
Merge a menu governor fix for 6.17-rc3 * pm-cpuidle: cpuidle: governors: menu: Avoid selecting states with too much latency
2 parents 2bc1adb + 779b1a1 commit 094a7c3

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

  • drivers/cpuidle/governors

drivers/cpuidle/governors/menu.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -287,20 +287,15 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
287287
return 0;
288288
}
289289

290-
if (tick_nohz_tick_stopped()) {
291-
/*
292-
* If the tick is already stopped, the cost of possible short
293-
* idle duration misprediction is much higher, because the CPU
294-
* may be stuck in a shallow idle state for a long time as a
295-
* result of it. In that case say we might mispredict and use
296-
* the known time till the closest timer event for the idle
297-
* state selection.
298-
*/
299-
if (predicted_ns < TICK_NSEC)
300-
predicted_ns = data->next_timer_ns;
301-
} else if (latency_req > predicted_ns) {
302-
latency_req = predicted_ns;
303-
}
290+
/*
291+
* If the tick is already stopped, the cost of possible short idle
292+
* duration misprediction is much higher, because the CPU may be stuck
293+
* in a shallow idle state for a long time as a result of it. In that
294+
* case, say we might mispredict and use the known time till the closest
295+
* timer event for the idle state selection.
296+
*/
297+
if (tick_nohz_tick_stopped() && predicted_ns < TICK_NSEC)
298+
predicted_ns = data->next_timer_ns;
304299

305300
/*
306301
* Find the idle state with the lowest power while satisfying
@@ -316,13 +311,15 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
316311
if (idx == -1)
317312
idx = i; /* first enabled state */
318313

314+
if (s->exit_latency_ns > latency_req)
315+
break;
316+
319317
if (s->target_residency_ns > predicted_ns) {
320318
/*
321319
* Use a physical idle state, not busy polling, unless
322320
* a timer is going to trigger soon enough.
323321
*/
324322
if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) &&
325-
s->exit_latency_ns <= latency_req &&
326323
s->target_residency_ns <= data->next_timer_ns) {
327324
predicted_ns = s->target_residency_ns;
328325
idx = i;
@@ -354,8 +351,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
354351

355352
return idx;
356353
}
357-
if (s->exit_latency_ns > latency_req)
358-
break;
359354

360355
idx = i;
361356
}

0 commit comments

Comments
 (0)