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

Commit 64510d47 authored by Syed Rameez Mustafa's avatar Syed Rameez Mustafa
Browse files

sched: Don't active migrate tasks to CPUs in the same cluster



At the tick the scheduler checks whether a running task needs to
be migrated for some reason. If the reason is to up or down migrate
a task, we should only kick active balance when select_best_cpu()
returns a CPU in the appropriate cluster. Active migrating a task
to another CPU in the same cluster is wasteful.

Change-Id: I2c899a9c2dfb8ec4f983d7e355f0960f88bd3b45
Signed-off-by: default avatarSyed Rameez Mustafa <rameezmustafa@codeaurora.org>
parent 3d82d664
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -3536,6 +3536,16 @@ kick_active_balance(struct rq *rq, struct task_struct *p, int new_cpu)

static DEFINE_RAW_SPINLOCK(migration_lock);

static bool do_migration(int reason, int new_cpu, int cpu)
{
	if ((reason == UP_MIGRATION || reason == DOWN_MIGRATION)
				&& same_cluster(new_cpu, cpu))
		return false;

	/* Inter cluster high irqload migrations are OK */
	return new_cpu != cpu;
}

/*
 * Check if currently running task should be migrated to a better cpu.
 *
@@ -3553,7 +3563,7 @@ void check_for_migration(struct rq *rq, struct task_struct *p)
	raw_spin_lock(&migration_lock);
	new_cpu = select_best_cpu(p, cpu, reason, 0);

	if (new_cpu != cpu) {
	if (do_migration(reason, new_cpu, cpu)) {
		active_balance = kick_active_balance(rq, p, new_cpu);
		if (active_balance)
			mark_reserved(new_cpu);