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

Commit cb1ec8a9 authored by Morten Rasmussen's avatar Morten Rasmussen Committed by Satya Durga Srinivasu Prabhala
Browse files

FROMLIST: sched: Add sched_group per-cpu max capacity



The current sg->min_capacity tracks the lowest per-cpu compute capacity
available in the sched_group when rt/irq pressure is taken into account.
Minimum capacity isn't the ideal metric for tracking if a sched_group
needs offloading to another sched_group for some scenarios, e.g. a
sched_group with multiple cpus if only one is under heavy pressure.
Tracking maximum capacity isn't perfect either but a better choice for
some situations as it indicates that the sched_group definitely compute
capacity constrained either due to rt/irq pressure on all cpus or
asymmetric cpu capacities (e.g. big.LITTLE).

cc: Ingo Molnar <mingo@redhat.com>
cc: Peter Zijlstra <peterz@infradead.org>

Change-Id: Ic96c914f7f969b8aa353cfa3ad287e0e628b1793
Signed-off-by: default avatarMorten Rasmussen <morten.rasmussen@arm.com>
[from https://lore.kernel.org/lkml/1530699470-29808-4-git-send-email-morten.rasmussen@arm.com/

]
[backported - some of this is already present in android-4.14]
Signed-off-by: default avatarValentin Schneider <valentin.schneider@arm.com>
Signed-off-by: default avatarChris Redpath <chris.redpath@arm.com>
Git-commit: a07aeacb
Git-repo: https://android.googlesource.com/kernel/common/


[pujag@codeaurora.org: replace capacity_margin with
sched_capacity_margin_up]
Signed-off-by: default avatarPuja Gupta <pujag@codeaurora.org>
parent 2cb0176a
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -9313,6 +9313,7 @@ static void update_cpu_capacity(struct sched_domain *sd, int cpu)
	cpu_rq(cpu)->cpu_capacity = capacity;
	sdg->sgc->capacity = capacity;
	sdg->sgc->min_capacity = capacity;
	sdg->sgc->max_capacity = capacity;
}

void update_group_capacity(struct sched_domain *sd, int cpu)
@@ -9488,17 +9489,29 @@ group_is_overloaded(struct lb_env *env, struct sg_lb_stats *sgs)
}

/*
 * group_smaller_cpu_capacity: Returns true if sched_group sg has smaller
 * group_smaller_min_cpu_capacity: Returns true if sched_group sg has smaller
 * per-CPU capacity than sched_group ref.
 */
static inline bool
group_smaller_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
group_smaller_min_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
{
	return sg->sgc->min_capacity *
				sched_capacity_margin_up[group_first_cpu(sg)] <
						ref->sgc->min_capacity * 1024;
}

/*
 * group_smaller_max_cpu_capacity: Returns true if sched_group sg has smaller
 * per-CPU capacity_orig than sched_group ref.
 */
static inline bool
group_smaller_max_cpu_capacity(struct sched_group *sg, struct sched_group *ref)
{
	return sg->sgc->max_capacity *
				sched_capacity_margin_up[group_first_cpu(sg)] <
						ref->sgc->max_capacity * 1024;
}

/*
 * group_similar_cpu_capacity: Returns true if the minimum capacity of the
 * compared groups differ by less than 12.5%.
@@ -9639,7 +9652,7 @@ static bool update_sd_pick_busiest(struct lb_env *env,
	 * Don't try to pull misfit tasks we can't help.
	 */
	if (sgs->group_type == group_misfit_task &&
	    (!group_smaller_cpu_capacity(sg, sds->local) ||
	    (!group_smaller_min_cpu_capacity(sg, sds->local) ||
	     !group_has_capacity(env, &sds->local_stat)))
		return false;

@@ -9662,7 +9675,7 @@ static bool update_sd_pick_busiest(struct lb_env *env,
	 * power/energy consequences are not considered.
	 */
	if (sgs->sum_nr_running <= sgs->group_weight &&
	    group_smaller_cpu_capacity(sds->local, sg))
	    group_smaller_min_cpu_capacity(sds->local, sg))
		return false;

	/*
+1 −0
Original line number Diff line number Diff line
@@ -915,6 +915,7 @@ static struct sched_group *get_group(int cpu, struct sd_data *sdd)

	sg->sgc->capacity = SCHED_CAPACITY_SCALE * cpumask_weight(sched_group_span(sg));
	sg->sgc->min_capacity = SCHED_CAPACITY_SCALE;
	sg->sgc->max_capacity = SCHED_CAPACITY_SCALE;

	return sg;
}