Commit 17224c1d authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarChristian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/2389215.ElGaqSPkdT@rafael.j.wysocki
parent 779b1a1c
Loading
Loading
Loading
Loading
+36 −34
Original line number Diff line number Diff line
@@ -314,10 +314,14 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
		if (s->exit_latency_ns > latency_req)
			break;

		if (s->target_residency_ns > predicted_ns) {
		if (s->target_residency_ns <= predicted_ns) {
			idx = i;
			continue;
		}

		/*
			 * Use a physical idle state, not busy polling, unless
			 * a timer is going to trigger soon enough.
		 * Use a physical idle state, not busy polling, unless a timer
		 * is going to trigger soon enough.
		 */
		if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) &&
		    s->target_residency_ns <= data->next_timer_ns) {
@@ -325,25 +329,26 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
			idx = i;
			break;
		}

		if (predicted_ns < TICK_NSEC)
			break;

		if (!tick_nohz_tick_stopped()) {
			/*
				 * If the state selected so far is shallow,
				 * waking up early won't hurt, so retain the
				 * tick in that case and let the governor run
				 * again in the next iteration of the loop.
			 * If the state selected so far is shallow, waking up
			 * early won't hurt, so retain the tick in that case and
			 * let the governor run again in the next iteration of
			 * the idle loop.
			 */
			predicted_ns = drv->states[idx].target_residency_ns;
			break;
		}

		/*
			 * If the state selected so far is shallow and this
			 * state's target residency matches the time till the
			 * closest timer event, select this one to avoid getting
			 * stuck in the shallow one for too long.
		 * If the state selected so far is shallow and this state's
		 * target residency matches the time till the closest timer
		 * event, select this one to avoid getting stuck in the shallow
		 * one for too long.
		 */
		if (drv->states[idx].target_residency_ns < TICK_NSEC &&
		    s->target_residency_ns <= delta_tick)
@@ -352,9 +357,6 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
		return idx;
	}

		idx = i;
	}

	if (idx == -1)
		idx = 0; /* No states enabled. Must use 0. */