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

Commit 4044207c authored by Pavankumar Kondeti's avatar Pavankumar Kondeti
Browse files

sched/fair: Fix previous CPU util calculation in cpu_util_next_walt()



When a task is waking and both evaluation CPU and the destination
CPU are the task's previous CPU, the task utilization must be
added to the evaluation CPU's utilization. But it is not done.
Due to this the task may get placed on the previous CPU incorrectly
and results in suboptimal power and performance.

Change-Id: I62b5eec3046b7fef31321125dd76f67afe8f567d
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent 88aaac7a
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -7202,11 +7202,37 @@ cpu_util_next_walt(int cpu, struct task_struct *p, int dst_cpu)
			cpu_rq(cpu)->walt_stats.cumulative_runnable_avg_scaled;
	bool queued = task_on_rq_queued(p);

	if (unlikely(queued && task_cpu(p) == cpu && dst_cpu != cpu))
	/*
	 * When task is queued,
	 * (a) The evaluating CPU (cpu) is task's current CPU. If the
	 * task is migrating, discount the task contribution from the
	 * evaluation cpu.
	 * (b) The evaluating CPU (cpu) is task's current CPU. If the
	 * task is NOT migrating, nothing to do. The contribution is
	 * already present on the evaluation CPU.
	 * (c) The evaluating CPU (cpu) is not task's current CPU. But
	 * the task is migrating to the evaluating CPU. So add the
	 * task contribution to it.
	 * (d) The evaluating CPU (cpu) is neither the current CPU nor
	 * the destination CPU. don't care.
	 *
	 * When task is NOT queued i.e waking. Task contribution is not
	 * present on any CPU.
	 *
	 * (a) If the evaluating CPU is the destination CPU, add the task
	 * contribution.
	 * (b) The evaluation CPU is not the destination CPU, don't care.
	 */
	if (unlikely(queued)) {
		if (task_cpu(p) == cpu) {
			if (dst_cpu != cpu)
				util = max_t(long, util - task_util(p), 0);
	else if (task_cpu(p) != cpu && dst_cpu == cpu &&
						p->state == TASK_WAKING)
		} else if (dst_cpu == cpu) {
			util += task_util(p);
		}
	} else if (dst_cpu == cpu) {
		util += task_util(p);
	}

	return min_t(unsigned long, util, capacity_orig_of(cpu));
}