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

Commit 16fa0667 authored by Syed Rameez Mustafa's avatar Syed Rameez Mustafa Committed by Steve Muckle
Browse files

sched: Disable interrupts when holding the rq lock in sched_get_busy()



Interrupts can end up waking processes on the same cpu as the one for
which sched_get_busy() is called. Since sched_get_busy() takes the rq
lock this can result in a deadlock as the same rq lock is required to
enqueue the waking up task. Fix the deadlock by disabling interrupts
when taking the rq lock.

Change-Id: I46e14a14789c2fb0ead42363fbaaa0a303a5818f
Signed-off-by: default avatarSyed Rameez Mustafa <rameezmustafa@codeaurora.org>
parent 93618440
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1397,6 +1397,7 @@ static inline void migrate_sync_cpu(int cpu)

unsigned long sched_get_busy(int cpu)
{
	unsigned long flags;
	struct rq *rq = cpu_rq(cpu);

	/*
@@ -1404,9 +1405,9 @@ unsigned long sched_get_busy(int cpu)
	 * current task may have been executing for a long time. Ensure
	 * that the window stats are current by doing an update.
	 */
	raw_spin_lock(&rq->lock);
	raw_spin_lock_irqsave(&rq->lock, flags);
	update_task_ravg(rq->curr, rq, TASK_UPDATE, sched_clock(), NULL);
	raw_spin_unlock(&rq->lock);
	raw_spin_unlock_irqrestore(&rq->lock, flags);

	return div64_u64(scale_load_to_cpu(rq->prev_runnable_sum, cpu),
			  NSEC_PER_USEC);