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

Commit 7fb3e0c9 authored by Quentin Perret's avatar Quentin Perret Committed by Andres Oportus
Browse files

ANDROID: Partial Revert: "ANDROID: sched: Add cpu capacity awareness to wakeup balancing"



Revert most of changes of commit b9ac0094.
Keep infrastructure bits used in following EAS patches. Fix task_util
return type.

Change-Id: Ic545ac745d00f19f7b6567d4b4b8d4bde32a95ca
Signed-off-by: default avatarQuentin Perret <quentin.perret@arm.com>
parent 0df28983
Loading
Loading
Loading
Loading
+21 −30
Original line number Diff line number Diff line
@@ -5690,7 +5690,7 @@ static int wake_affine(struct sched_domain *sd, struct task_struct *p,
	return 1;
}

static inline int task_util(struct task_struct *p)
static inline unsigned long task_util(struct task_struct *p)
{
#ifdef CONFIG_SCHED_WALT
	if (!walt_disabled && sysctl_sched_use_walt_task_util) {
@@ -5726,11 +5726,6 @@ static inline bool task_fits_max(struct task_struct *p, int cpu)
	return __task_fits(p, cpu, 0);
}

static inline bool task_fits_spare(struct task_struct *p, int cpu)
{
	return __task_fits(p, cpu, cpu_util(cpu));
}

static bool cpu_overutilized(int cpu)
{
	return (capacity_of(cpu) * 1024) < (cpu_util(cpu) * capacity_margin);
@@ -5862,9 +5857,7 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p,
		  int this_cpu, int sd_flag)
{
	struct sched_group *idlest = NULL, *group = sd->groups;
	struct sched_group *fit_group = NULL;
	unsigned long min_load = ULONG_MAX, this_load = 0;
	unsigned long fit_capacity = ULONG_MAX;
	int load_idx = sd->forkexec_idx;
	int imbalance = 100 + (sd->imbalance_pct-100)/2;

@@ -5896,14 +5889,6 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p,

			avg_load += load;

			/*
			 * Look for most energy-efficient group that can fit
			 * that can fit the task.
			 */
			if (capacity_of(i) < fit_capacity && task_fits_spare(p, i)) {
				fit_capacity = capacity_of(i);
				fit_group = group;
			}
		}

		/* Adjust by relative CPU capacity of the group */
@@ -5917,9 +5902,6 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p,
		}
	} while (group = group->next, group != sd->groups);

	if (fit_group)
		return fit_group;

	if (!idlest || 100*this_load < imbalance*min_load)
		return NULL;
	return idlest;
@@ -5944,7 +5926,7 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)

	/* Traverse only the allowed CPUs */
	for_each_cpu_and(i, sched_group_cpus(group), tsk_cpus_allowed(p)) {
		if (task_fits_spare(p, i)) {
		if (idle_cpu(i)) {
			struct rq *rq = cpu_rq(i);
			struct cpuidle_state *idle = idle_get_state(rq);
			if (idle && idle->exit_latency < min_exit_latency) {
@@ -5956,8 +5938,7 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
				min_exit_latency = idle->exit_latency;
				latest_idle_timestamp = rq->idle_stamp;
				shallowest_idle_cpu = i;
			} else if (idle_cpu(i) &&
				   (!idle || idle->exit_latency == min_exit_latency) &&
			} else if ((!idle || idle->exit_latency == min_exit_latency) &&
				   rq->idle_stamp > latest_idle_timestamp) {
				/*
				 * If equal or no active idle state, then
@@ -5966,13 +5947,6 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
				 */
				latest_idle_timestamp = rq->idle_stamp;
				shallowest_idle_cpu = i;
			} else if (shallowest_idle_cpu == -1) {
				/*
				 * If we haven't found an idle CPU yet
				 * pick a non-idle one that can fit the task as
				 * fallback.
				 */
				shallowest_idle_cpu = i;
			}
		} else if (shallowest_idle_cpu == -1) {
			load = weighted_cpuload(i);
@@ -6338,6 +6312,23 @@ static inline int find_best_target(struct task_struct *p, bool boosted, bool pre
	return target_cpu;
}

/*
 * Disable WAKE_AFFINE in the case where task @p doesn't fit in the
 * capacity of either the waking CPU @cpu or the previous CPU @prev_cpu.
 * 
 * In that case WAKE_AFFINE doesn't make sense and we'll let
 * BALANCE_WAKE sort things out.
 */
static int wake_cap(struct task_struct *p, int cpu, int prev_cpu)
{
	long min_cap, max_cap;
	min_cap = min(capacity_orig_of(prev_cpu), capacity_orig_of(cpu));
	max_cap = cpu_rq(cpu)->rd->max_cpu_capacity.val;
	/* Minimum capacity is close to max, no need to abort wake_affine */
	if (max_cap - min_cap < max_cap >> 3)
		return 0;
	return min_cap * 1024 < task_util(p) * capacity_margin;
}

/*
 * select_task_rq_fair: Select target runqueue for the waking task in domains
@@ -6362,7 +6353,7 @@ select_task_rq_fair(struct task_struct *p, int prev_cpu, int sd_flag, int wake_f

	if (sd_flag & SD_BALANCE_WAKE) {
		record_wakee(p);
		want_affine = (!wake_wide(p) && task_fits_max(p, cpu) &&
		want_affine = (!wake_wide(p) && !wake_cap(p, cpu, prev_cpu) &&
			cpumask_test_cpu(cpu, tsk_cpus_allowed(p)));
	}