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

Commit eb68aa79 authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Joonwoo Park
Browse files

sched: EAS: colocate related threads



Add colocation awareness to energy aware task placement and
load balancer. For related threads, select the CPU in the
preferred cluster if the task can fit there. Otherwise break
the colocation and select the cluster on which the task can fit.

Change-Id: Iff53251f4a353090341210ae5834e92fc5b43613
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent e2562921
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -869,6 +869,11 @@ DECLARE_EVENT_CLASS(sched_task_util,
		__entry->comm, __entry->pid, __entry->task_cpu, __entry->task_util, __entry->nominated_cpu, __entry->target_cpu, __entry->ediff, __entry->need_idle, __entry->latency)
);

DEFINE_EVENT(sched_task_util, sched_task_util_colocated,
	TP_PROTO(struct task_struct *p, int task_cpu, unsigned long task_util, int nominated_cpu, int target_cpu, int ediff, bool need_idle),
	TP_ARGS(p, task_cpu, task_util, nominated_cpu, target_cpu, ediff, need_idle)
);

DEFINE_EVENT(sched_task_util, sched_task_util_overutilzed,
	TP_PROTO(struct task_struct *p, int task_cpu, unsigned long task_util, int nominated_cpu, int target_cpu, int ediff, bool need_idle),
	TP_ARGS(p, task_cpu, task_util, nominated_cpu, target_cpu, ediff, need_idle)
+43 −6
Original line number Diff line number Diff line
@@ -6681,6 +6681,7 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target, int sync)
	bool safe_to_pack = false;
	unsigned int target_cpu_util = UINT_MAX;
	long target_cpu_new_util_cum = LONG_MAX;
	struct cpumask *rtg_target = NULL;
	bool need_idle;
	bool skip_ediff = false;

@@ -6698,6 +6699,15 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target, int sync)
	need_idle = wake_to_idle(p);

	if (sysctl_sched_is_big_little) {
		struct related_thread_group *grp;

		rcu_read_lock();
		grp = task_related_thread_group(p);
		rcu_read_unlock();

		if (grp && grp->preferred_cluster)
			rtg_target = &grp->preferred_cluster->cpus;

		task_util_boosted = boosted_task_util(p);

		/*
@@ -6720,7 +6730,20 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target, int sync)
			    task_fits_max(p, max_cap_cpu)) {
				sg_target = sg;

				if (sync && curr_util >= task_util_boosted) {
				if (rtg_target) {
					/*
					 * For tasks that belong to a related
					 * thread group, select the preferred
					 * cluster if the task can fit there,
					 * otherwise select the cluster which
					 * can fit the task.
					 */
					if (cpumask_test_cpu(max_cap_cpu,
							     rtg_target))
						break;
					continue;
				} else if (sync && curr_util >=
					   task_util_boosted) {
					if (cpumask_test_cpu(cpu,
							sched_group_cpus(sg))) {
						if (!cpumask_test_cpu(task_cpu(p),
@@ -6887,6 +6910,20 @@ static int energy_aware_wake_cpu(struct task_struct *p, int target, int sync)
			.curr_util	= curr_util,
		};

		/*
		 * If the previous CPU does not belong to the preferred_cluster,
		 * there is no need to evaluate energy difference. We want
		 * to migrate the task to the preferred cluster.
		 *
		 */
		if (rtg_target && !cpumask_test_cpu(eenv.src_cpu, rtg_target)) {
			trace_sched_task_util_colocated(p, task_cpu(p),
						task_util(p),
						cpumask_first(rtg_target),
						target_cpu, 0, need_idle);
			return target_cpu;
		}

#ifdef CONFIG_SCHED_WALT
		if (walt_disabled || !sysctl_sched_use_walt_cpu_util)
			task_util_boosted = 0;
@@ -7782,6 +7819,10 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
	env->flags &= ~LBF_ALL_PINNED;

#ifdef CONFIG_SCHED_WALT
	if (env->flags & LBF_IGNORE_PREFERRED_CLUSTER_TASKS &&
			 !preferred_cluster(cpu_rq(env->dst_cpu)->cluster, p))
		return 0;

	/* Don't detach task if it doesn't fit on the destination */
	if (env->flags & LBF_IGNORE_BIG_TASKS &&
		!task_fits_max(p, env->dst_cpu))
@@ -7807,10 +7848,6 @@ int can_migrate_task(struct task_struct *p, struct lb_env *env)
	if (env->flags & LBF_IGNORE_BIG_TASKS && !twf)
		return 0;

	if (env->flags & LBF_IGNORE_PREFERRED_CLUSTER_TASKS &&
	    !preferred_cluster(rq_cluster(cpu_rq(env->dst_cpu)), p))
		return 0;

	/*
	 * Group imbalance can sometimes cause work to be pulled across groups
	 * even though the group could have managed the imbalance on its own.
+2 −2
Original line number Diff line number Diff line
@@ -2229,7 +2229,7 @@ int __read_mostly sched_freq_aggregate_threshold;
 * Task groups whose aggregate demand on a cpu is more than
 * sched_group_upmigrate need to be up-migrated if possible.
 */
unsigned int __read_mostly sched_group_upmigrate;
unsigned int __read_mostly sched_group_upmigrate = 10000000;
unsigned int __read_mostly sysctl_sched_group_upmigrate_pct = 100;

/*
@@ -2237,7 +2237,7 @@ unsigned int __read_mostly sysctl_sched_group_upmigrate_pct = 100;
 * demand to less than sched_group_downmigrate before they are "down"
 * migrated.
 */
unsigned int __read_mostly sched_group_downmigrate;
unsigned int __read_mostly sched_group_downmigrate = 9500000;
unsigned int __read_mostly sysctl_sched_group_downmigrate_pct = 95;

static int