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

Commit dc6f7513 authored by Chris Redpath's avatar Chris Redpath Committed by Ionela Voinescu
Browse files

ANDROID: sched/fair: return idle CPU immediately for prefer_idle



When a CPU is selected for a prefer_idle task through find_best_target
this CPU will become a target CPU on which we perform an energy diff and
select between the previous CPU and the target CPU based on the estimated
energy consumption for both placements.

For prefer_idle tasks we should favour performance over energy savings
and therefore return a found idle CPU immediately.

Change-Id: I2242a51134ac172dd58b3b08375388a7b4b84af0
Signed-off-by: default avatarIonela Voinescu <ionela.voinescu@arm.com>
Signed-off-by: default avatarChris Redpath <chris.redpath@arm.com>
Suggested-by: default avatarJoel Fernandes <joelaf@google.com>
parent 5f574ff1
Loading
Loading
Loading
Loading
+14 −8
Original line number Diff line number Diff line
@@ -7391,7 +7391,7 @@ static int find_energy_efficient_cpu(struct sched_domain *sd,
{
	int use_fbt = sched_feat(FIND_BEST_TARGET);
	int cpu_iter, eas_cpu_idx = EAS_CPU_NXT;
	int energy_cpu = -1;
	int target_cpu = -1;
	struct energy_env *eenv;

	if (sysctl_sched_sync_hint_enable && sync) {
@@ -7403,7 +7403,7 @@ static int find_energy_efficient_cpu(struct sched_domain *sd,
	/* prepopulate energy diff environment */
	eenv = get_eenv(p, prev_cpu);
	if (eenv->max_cpu_count < 2)
		return energy_cpu;
		return -1;

	if(!use_fbt) {
		/*
@@ -7448,10 +7448,16 @@ static int find_energy_efficient_cpu(struct sched_domain *sd,
		eenv->max_cpu_count = EAS_CPU_BKP + 1;

		/* Find a cpu with sufficient capacity */
		eenv->cpu[EAS_CPU_NXT].cpu_id = find_best_target(p,
				&eenv->cpu[EAS_CPU_BKP].cpu_id,
		target_cpu = find_best_target(p, &eenv->cpu[EAS_CPU_BKP].cpu_id,
					      boosted, prefer_idle);

		/* Immediately return a found idle CPU for a prefer_idle task */
		if (prefer_idle && target_cpu >= 0 && idle_cpu(target_cpu))
			return target_cpu;

		/* Place target into NEXT slot */
		eenv->cpu[EAS_CPU_NXT].cpu_id = target_cpu;

		/* take note if no backup was found */
		if (eenv->cpu[EAS_CPU_BKP].cpu_id < 0)
			eenv->max_cpu_count = EAS_CPU_BKP;
@@ -7467,14 +7473,14 @@ static int find_energy_efficient_cpu(struct sched_domain *sd,
		 * candidates beyond prev_cpu, so we will
		 * fall-back to the regular slow-path.
		 */
		return energy_cpu;
		return -1;
	}

	/* find most energy-efficient CPU */
	energy_cpu = select_energy_cpu_idx(eenv) < 0 ? -1 :
	target_cpu = select_energy_cpu_idx(eenv) < 0 ? -1 :
					eenv->cpu[eenv->next_idx].cpu_id;

	return energy_cpu;
	return target_cpu;
}

static inline bool nohz_kick_needed(struct rq *rq, bool only_update);