Commit 650952d3 authored by Peter Zijlstra's avatar Peter Zijlstra
Browse files

sched: Make __do_set_cpus_allowed() use the sched_change pattern



Now that do_set_cpus_allowed() holds all the regular locks, convert it
to use the sched_change pattern helper.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarJuri Lelli <juri.lelli@redhat.com>
Acked-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
parent b079d937
Loading
Loading
Loading
Loading
+5 −21
Original line number Diff line number Diff line
@@ -2664,28 +2664,12 @@ void set_cpus_allowed_common(struct task_struct *p, struct affinity_context *ctx
static void
do_set_cpus_allowed(struct task_struct *p, struct affinity_context *ctx)
{
	struct rq *rq = task_rq(p);
	bool queued, running;

	lockdep_assert_held(&p->pi_lock);
	lockdep_assert_rq_held(rq);

	queued = task_on_rq_queued(p);
	running = task_current_donor(rq, p);

	if (queued)
		dequeue_task(rq, p, DEQUEUE_SAVE | DEQUEUE_NOCLOCK);

	if (running)
		put_prev_task(rq, p);
	u32 flags = DEQUEUE_SAVE | DEQUEUE_NOCLOCK;

	scoped_guard (sched_change, p, flags) {
		p->sched_class->set_cpus_allowed(p, ctx);
		mm_set_cpus_allowed(p->mm, ctx->new_mask);

	if (queued)
		enqueue_task(rq, p, ENQUEUE_RESTORE | ENQUEUE_NOCLOCK);
	if (running)
		set_next_task(rq, p);
	}
}

/*