From 89288d853b2a7a221e24bdf4286b16359a5ee954 Mon Sep 17 00:00:00 2001
From: Srinath Sridharan <srinathsr@google.com>
Date: Wed, 13 Jul 2016 17:45:49 -0700
Subject: [PATCH] sched/rt: Avoid moving rt task if destination CPU does not
 run low priority task.

bug: 29512132
bug: 30115868
Change-Id: Id18083402dfe2324f86c34a4e5d32fb7e0d11d04
---
 kernel/sched/rt.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 684819921c93..24ad9f1deb83 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1395,7 +1395,12 @@ select_task_rq_rt(struct task_struct *p, int cpu, int sd_flag, int flags)
 	     curr->prio <= p->prio)) {
 		int target = find_lowest_rq(p);
 
-		if (target != -1)
+		/*
+		 * Possible race. Don't bother moving it if the
+		 * destination CPU is not running a lower priority task.
+		 */
+                if (target != -1 &&
+                    p->prio < cpu_rq(target)->rt.highest_prio.curr)
 			cpu = target;
 	}
 	rcu_read_unlock();
-- 
GitLab