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

Commit 5383285d authored by Ionela Voinescu's avatar Ionela Voinescu
Browse files

ANDROID: sched/fair: unify spare capacity calculation



Given that we have a few sites where the spare capacity of a CPU is
calculated as the difference between the original capacity of the CPU
and its computed new utilization, let's unify the calculation and use
that value tracked with a local spare_cap variable.

Change-Id: I78daece7543f78d4f74edbee5e9ceb62908af507
Signed-off-by: default avatarIonela Voinescu <ionela.voinescu@arm.com>
parent 03429a53
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -6941,6 +6941,7 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
			unsigned long capacity_curr = capacity_curr_of(i);
			unsigned long capacity_orig = capacity_orig_of(i);
			unsigned long wake_util, new_util;
			long spare_cap;

			if (!cpu_online(i))
				continue;
@@ -6965,6 +6966,13 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
			if (new_util > capacity_orig)
				continue;

			/*
			 * Pre-compute the maximum possible capacity we expect
			 * to have available on this CPU once the task is
			 * enqueued here.
			 */
			spare_cap = capacity_orig - new_util;

			/*
			 * Case A) Latency sensitive tasks
			 *
@@ -7012,9 +7020,9 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
				 * Case A.2: Target ACTIVE CPU
				 * Favor CPUs with max spare capacity.
				 */
				if ((capacity_curr > new_util) &&
					(capacity_orig - new_util > target_max_spare_cap)) {
					target_max_spare_cap = capacity_orig - new_util;
				if (capacity_curr > new_util &&
				    spare_cap > target_max_spare_cap) {
					target_max_spare_cap = spare_cap;
					target_cpu = i;
					continue;
				}
@@ -7124,10 +7132,10 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,

			/* Favor CPUs with maximum spare capacity */
			if (capacity_orig == target_capacity &&
			    (capacity_orig - new_util) < target_max_spare_cap)
			    spare_cap < target_max_spare_cap)
				continue;

			target_max_spare_cap = capacity_orig - new_util;
			target_max_spare_cap = spare_cap;
			target_capacity = capacity_orig;
			target_util = new_util;
			target_cpu = i;