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

Commit 0c0d18bb authored by Olav Haugan's avatar Olav Haugan
Browse files

sched: Only do EA migration when CPU throttling is imminent



We do not want to migrate tasks unnecessary to avoid cache hit and other
migration latencies that could affect the performance of the system. Add
a check to only try EA migration when CPU frequency throttling is
imminent.

CRs-Fixed: 764788
Change-Id: I92e86e62da10ce15f1e76a980df3545e93d76348
Signed-off-by: default avatarOlav Haugan <ohaugan@codeaurora.org>
parent 32c6ac7c
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -2308,6 +2308,8 @@ static int lower_power_cpu_available(struct task_struct *p, int cpu)
	return (lowest_power_cpu != task_cpu(p));
}

static inline int is_cpu_throttling_imminent(int cpu);

/*
 * Check if a task is on the "wrong" cpu (i.e its current cpu is not the ideal
 * cpu as per its demand or priority)
@@ -2340,6 +2342,7 @@ static inline int migration_needed(struct rq *rq, struct task_struct *p)
		return MOVE_TO_BIG_CPU;

	if (sched_enable_power_aware &&
	    is_cpu_throttling_imminent(cpu_of(rq)) &&
	    lower_power_cpu_available(p, cpu_of(rq)))
		return MOVE_TO_POWER_EFFICIENT_CPU;

@@ -2403,6 +2406,16 @@ static inline int nr_big_tasks(struct rq *rq)
	return rq->nr_big_tasks;
}

static inline int is_cpu_throttling_imminent(int cpu)
{
	int throttling = 0;
	struct cpu_pwr_stats *per_cpu_info = get_cpu_pwr_stats();

	if (per_cpu_info)
		throttling = per_cpu_info[cpu].throttling;
	return throttling;
}

#else	/* CONFIG_SCHED_HMP */

#define sched_enable_power_aware 0
@@ -2459,6 +2472,11 @@ static inline int nr_big_tasks(struct rq *rq)
	return 0;
}

static inline int is_cpu_throttling_imminent(int cpu)
{
	return 0;
}

#endif	/* CONFIG_SCHED_HMP */

#ifdef CONFIG_SCHED_HMP
@@ -6078,12 +6096,14 @@ static bool update_sd_pick_busiest(struct lb_env *env,
	}

	/* Mark a less power-efficient CPU as busy only if we haven't
	 * seen a busy group yet. We want to prioritize spreading
	 * work over power optimization. */
	 * seen a busy group yet and we are close to throttling. We want to
	 * prioritize spreading work over power optimization.
	 */
	if (!sds->busiest && (capacity(env->dst_rq) == group_rq_capacity(sg)) &&
	    sgs->sum_nr_running && (env->idle != CPU_NOT_IDLE) &&
	    power_cost_at_freq(env->dst_cpu, 0) <
	    power_cost_at_freq(cpumask_first(sched_group_cpus(sg)), 0)) {
	    power_cost_at_freq(cpumask_first(sched_group_cpus(sg)), 0) &&
	    is_cpu_throttling_imminent(cpumask_first(sched_group_cpus(sg)))) {
		env->flags |= LBF_PWR_ACTIVE_BALANCE;
		return true;
	}