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

Commit 0ced5701 authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Gerrit - the friendly Code Review server
Browse files

sched/fair: Fix incorrect CPU access in check_for_migration()



Commit 3a94de0b ("sched/fair: Prevent tick path active migration
to the same CPU") removed the -1 check for the return value of
find_energy_efficient_cpu() while adding the check against the
previous CPU. If the new CPU is -1, then it passes the check of
new_cpu != prev_cpu and end up calling capacity_orig_of() with
-1 as an argument. Fix this issue by adding the -1 check again.

Change-Id: I6768ef722f25885f97583e493a6753b5e3fe28ee
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent 5a4fd734
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -12503,8 +12503,8 @@ void check_for_migration(struct rq *rq, struct task_struct *p)
		rcu_read_lock();
		rcu_read_lock();
		new_cpu = find_energy_efficient_cpu(p, prev_cpu, 0);
		new_cpu = find_energy_efficient_cpu(p, prev_cpu, 0);
		rcu_read_unlock();
		rcu_read_unlock();
		if ((new_cpu != prev_cpu) && (capacity_orig_of(new_cpu) >
		if ((new_cpu != -1) && (new_cpu != prev_cpu) &&
					capacity_orig_of(prev_cpu))) {
		    (capacity_orig_of(new_cpu) > capacity_orig_of(prev_cpu))) {
			active_balance = kick_active_balance(rq, p, new_cpu);
			active_balance = kick_active_balance(rq, p, new_cpu);
			if (active_balance) {
			if (active_balance) {
				mark_reserved(new_cpu);
				mark_reserved(new_cpu);