Snapshot only if not previously force-idle

Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Change-Id: If7fae6b98d15dd847e2631bc82963990169807a2
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 79409ad..c876a3f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4076,12 +4076,12 @@
 static struct task_struct *
 pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf)
 {
-	struct cfs_rq *cfs_rq[2];
 	struct task_struct *next, *max = NULL;
 	const struct sched_class *class;
 	const struct cpumask *smt_mask;
 	int i, j, cpu, occ = 0;
 	bool need_sync = false;
+	bool fi_before = false;
 
 	cpu = cpu_of(rq);
 	if (cpu_is_offline(cpu))
@@ -4155,6 +4155,7 @@
 			update_rq_clock(rq_i);
 	}
 
+	fi_before = need_sync;
 	if (!need_sync) {
 		for_each_cpu(i, smt_mask) {
 			struct rq *rq_i = cpu_rq(i);
@@ -4316,12 +4317,13 @@
 		}
 	}
 
-	if (need_sync) {
+	if (!fi_before && need_sync) {
 		for_each_cpu(i, smt_mask) {
 			struct rq *rq_i = cpu_rq(i);
 
 			/* Snapshot if core is in force-idle. */
 			rq_i->cfs.min_vruntime_fi = rq_i->cfs.min_vruntime;
+			trace_printk("Snapshotting mvr for %d = %Lu [ns]\n", i, rq_i->cfs.min_vruntime);
 		}
 	}
 done: