Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f574ff1 authored by Ionela Voinescu's avatar Ionela Voinescu
Browse files

ANDROID: sched/fair: add idle state filter to prefer_idle case



The CPU selection process for a prefer_idle task either minimizes or
maximizes the CPU capacity for idle CPUs depending on the task being
boosted or not.

Given that we are iterating through all CPUs, additionally filter the
choice by preferring a CPU in a more shallow idle state. This will
provide both a faster wake-up for the task and higher energy efficiency,
by allowing CPUs in deeper idle states to remain idle.

Change-Id: Ic55f727a0c551adc0af8e6ee03de6a41337a571b
Signed-off-by: default avatarIonela Voinescu <ionela.voinescu@arm.com>
parent 19c03aff
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -6954,6 +6954,7 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
			unsigned long capacity_orig = capacity_orig_of(i);
			unsigned long wake_util, new_util;
			long spare_cap;
			int idle_idx = INT_MAX;

			if (!cpu_online(i))
				continue;
@@ -6985,6 +6986,10 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
			 */
			spare_cap = capacity_orig - new_util;

			if (idle_cpu(i))
				idle_idx = idle_get_state_idx(cpu_rq(i));


			/*
			 * Case A) Latency sensitive tasks
			 *
@@ -7025,13 +7030,18 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
				 */
				if (idle_cpu(i)) {
					if (boosted &&
					    capacity_orig <= target_capacity)
					    capacity_orig < target_capacity)
						continue;
					if (!boosted &&
					    capacity_orig >= target_capacity)
					    capacity_orig > target_capacity)
						continue;
					if (capacity_orig == target_capacity &&
					    sysctl_sched_cstate_aware &&
					    best_idle_cstate <= idle_idx)
						continue;

					target_capacity = capacity_orig;
					best_idle_cstate = idle_idx;
					best_idle_cpu = i;
					continue;
				}
@@ -7113,8 +7123,6 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
			 * consumptions without affecting performance.
			 */
			if (idle_cpu(i)) {
				int idle_idx = idle_get_state_idx(cpu_rq(i));

				/*
				 * Skip CPUs in deeper idle state, but only
				 * if they are also less energy efficient.