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

Commit 70a86fb7 authored by Abhijeet Dharmapurikar's avatar Abhijeet Dharmapurikar
Browse files

sched/fair: fix prefer_idle behaviour



prefer_idle is meant for reducing wake_latencies for the task and
hence such a task needs to be placed on an idle cpu and if idle
isn't available, the most spare active cpu.

Currently the code limits the search to the cluster of the
start_cpu, i.e. if an active cpu is found it uses it and doesn't
check for more clusters for idle cpu.

Fix this by allowing to search more clusters regardless of a cpu
is found. But still keep the optimization to break from searching
more groups based on schedtune boost and the capacity of next
cluster.

Change-Id: Ia488aabab448af83e427f6f57da8a7baae40278d
Signed-off-by: default avatarAbhijeet Dharmapurikar <adharmap@codeaurora.org>
parent 18eaaf28
Loading
Loading
Loading
Loading
+22 −3
Original line number Diff line number Diff line
@@ -7111,6 +7111,7 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
	int most_spare_cap_cpu = -1;
	unsigned int active_cpus_count = 0;
	int prev_cpu = task_cpu(p);
	bool next_group_higher_cap = false;

	*backup_cpu = -1;

@@ -7420,18 +7421,36 @@ static inline int find_best_target(struct task_struct *p, int *backup_cpu,
			target_cpu = i;
		}

		next_group_higher_cap = (capacity_orig_of(group_first_cpu(sg)) <
			capacity_orig_of(group_first_cpu(sg->next)));

		/*
		 * If we've found a cpu, but the boost is ON_ALL we continue
		 * visiting other clusters. If the boost is ON_BIG we visit
		 * next cluster if they are higher in capacity. If we are
		 * not in any kind of boost, we break.
		 */
		if ((target_cpu != -1 || best_idle_cpu != -1) &&
		if (!prefer_idle &&
			(target_cpu != -1 || best_idle_cpu != -1) &&
			(fbt_env->placement_boost == SCHED_BOOST_NONE ||
			(fbt_env->placement_boost == SCHED_BOOST_ON_BIG &&
				(capacity_orig_of(group_first_cpu(sg)) >
				capacity_orig_of(group_first_cpu(sg->next))))))
				!next_group_higher_cap)))
			break;

		/*
		 * if we are in prefer_idle and have found an idle cpu,
		 * break from searching more groups based on the stune.boost and
		 * group cpu capacity.
		 */
		if (prefer_idle && best_idle_cpu != -1) {
			if (boosted) {
				if (!next_group_higher_cap)
					break;
			} else {
				if (next_group_higher_cap)
					break;
			}
		}

	} while (sg = sg->next, sg != sd->groups);