Skip to content

Commit 17224c1

Browse files
committed
cpuidle: governors: menu: Rearrange main loop in menu_select()
Reduce the indentation level in the main loop of menu_select() by rearranging some checks and assignments in it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Christian Loehle <christian.loehle@arm.com> Link: https://patch.msgid.link/2389215.ElGaqSPkdT@rafael.j.wysocki
1 parent 779b1a1 commit 17224c1

1 file changed

Lines changed: 36 additions & 34 deletions

File tree

  • drivers/cpuidle/governors

drivers/cpuidle/governors/menu.c

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -314,45 +314,47 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
314314
if (s->exit_latency_ns > latency_req)
315315
break;
316316

317-
if (s->target_residency_ns > predicted_ns) {
318-
/*
319-
* Use a physical idle state, not busy polling, unless
320-
* a timer is going to trigger soon enough.
321-
*/
322-
if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) &&
323-
s->target_residency_ns <= data->next_timer_ns) {
324-
predicted_ns = s->target_residency_ns;
325-
idx = i;
326-
break;
327-
}
328-
if (predicted_ns < TICK_NSEC)
329-
break;
330-
331-
if (!tick_nohz_tick_stopped()) {
332-
/*
333-
* If the state selected so far is shallow,
334-
* waking up early won't hurt, so retain the
335-
* tick in that case and let the governor run
336-
* again in the next iteration of the loop.
337-
*/
338-
predicted_ns = drv->states[idx].target_residency_ns;
339-
break;
340-
}
317+
if (s->target_residency_ns <= predicted_ns) {
318+
idx = i;
319+
continue;
320+
}
321+
322+
/*
323+
* Use a physical idle state, not busy polling, unless a timer
324+
* is going to trigger soon enough.
325+
*/
326+
if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) &&
327+
s->target_residency_ns <= data->next_timer_ns) {
328+
predicted_ns = s->target_residency_ns;
329+
idx = i;
330+
break;
331+
}
341332

333+
if (predicted_ns < TICK_NSEC)
334+
break;
335+
336+
if (!tick_nohz_tick_stopped()) {
342337
/*
343-
* If the state selected so far is shallow and this
344-
* state's target residency matches the time till the
345-
* closest timer event, select this one to avoid getting
346-
* stuck in the shallow one for too long.
338+
* If the state selected so far is shallow, waking up
339+
* early won't hurt, so retain the tick in that case and
340+
* let the governor run again in the next iteration of
341+
* the idle loop.
347342
*/
348-
if (drv->states[idx].target_residency_ns < TICK_NSEC &&
349-
s->target_residency_ns <= delta_tick)
350-
idx = i;
351-
352-
return idx;
343+
predicted_ns = drv->states[idx].target_residency_ns;
344+
break;
353345
}
354346

355-
idx = i;
347+
/*
348+
* If the state selected so far is shallow and this state's
349+
* target residency matches the time till the closest timer
350+
* event, select this one to avoid getting stuck in the shallow
351+
* one for too long.
352+
*/
353+
if (drv->states[idx].target_residency_ns < TICK_NSEC &&
354+
s->target_residency_ns <= delta_tick)
355+
idx = i;
356+
357+
return idx;
356358
}
357359

358360
if (idx == -1)

0 commit comments

Comments
 (0)