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

Commit 7b76c244 authored by Srivatsa Vaddagiri's avatar Srivatsa Vaddagiri Committed by Steve Muckle
Browse files

sched: Fix possibility of "stuck" reserved flag



check_for_migration() could mark a thread for migration (in
rq->push_task) and invoke active_load_balance_cpu_stop(). However that
thread could get migrated to another cpu by the time
active_load_balance_cpu_stop() runs, which could fail to clear
reserved flag for a cpu and drop task_sruct reference when cpu has
only one task (stopper thread running
active_load_balance_cpu_stop()). This would cause a cpu to have
reserved bit stuck, which prevents it from being used effectively.

Fix this by having active_load_balance_cpu_stop() drop reserved bit
always.

Change-Id: I2464a46b4ddb52376a95518bcc95dd9768e891f9
Signed-off-by: default avatarSrivatsa Vaddagiri <vatsa@codeaurora.org>
parent 0699a566
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -6723,14 +6723,12 @@ static int active_load_balance_cpu_stop(void *data)
	double_lock_balance(busiest_rq, target_rq);

	push_task = busiest_rq->push_task;
	target_cpu = busiest_rq->push_cpu;
	if (push_task) {
		if (push_task->on_rq && push_task->state == TASK_RUNNING &&
		    task_cpu(push_task) == busiest_cpu &&
		    cpu_online(target_cpu))
			move_task(push_task, &env);
		put_task_struct(push_task);
		clear_reserved(target_cpu);
		busiest_rq->push_task = NULL;
		goto out_unlock_balance;
	}

@@ -6756,6 +6754,13 @@ out_unlock_balance:
	double_unlock_balance(busiest_rq, target_rq);
out_unlock:
	busiest_rq->active_balance = 0;
	push_task = busiest_rq->push_task;
	target_cpu = busiest_rq->push_cpu;
	if (push_task) {
		put_task_struct(push_task);
		clear_reserved(target_cpu);
		busiest_rq->push_task = NULL;
	}
	raw_spin_unlock_irq(&busiest_rq->lock);
	if (per_cpu(dbs_boost_needed, target_cpu)) {
		struct migration_notify_data mnd;