From 9df828148e1848e04943a7413e49e300040870a7 Mon Sep 17 00:00:00 2001
Message-Id: <9df828148e1848e04943a7413e49e300040870a7.1426111457.git.amit.kucheria@linaro.org>
From: Amit Kucheria <amit.kucheria@linaro.org>
Date: Thu, 12 Mar 2015 03:30:42 +0530
Subject: [PATCH] Fix broken comparison mode

Commit 7f365110226a5cb350df98dc7270e851093c8668 tried to correctly order the frequencies in ascending order. But as a result, it seems to have broken the comparison reporting.

In fact, I can't see how merge_pstates() ever did what it claims to do in the comments - add "dummy" states only present in one trace into the other so that both sets of traces have the same set of states to compare.

Signed-off-by: Amit Kucheria <amit.kucheria@linaro.org>
---
 idlestat.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/idlestat.c b/idlestat.c
index 22a9781..02bac21 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -696,20 +696,13 @@ static void merge_pstates(struct cpuidle_datas *datas,
 		percpu_a = &(datas->pstates[cpu]);
 		percpu_b = &(baseline->pstates[cpu]);
 
-		for (idx = 0; idx < percpu_a->max && idx < percpu_b->max; ) {
-			if (percpu_a->pstate[idx].freq >
-					percpu_b->pstate[idx].freq) {
-				assert(alloc_pstate(percpu_b,
-					percpu_a->pstate[idx].freq) == idx);
+		for (idx = 0; idx < percpu_a->max && idx < percpu_b->max; ++idx) {
+			if (percpu_a->pstate[idx].freq == percpu_b->pstate[idx].freq) {
 				continue;
+			} else {
+				alloc_pstate(percpu_a, percpu_b->pstate[idx].freq);
+				alloc_pstate(percpu_b, percpu_a->pstate[idx].freq);
 			}
-			if (percpu_a->pstate[idx].freq <
-					percpu_b->pstate[idx].freq) {
-				assert(alloc_pstate(percpu_a,
-					percpu_b->pstate[idx].freq) == idx);
-				continue;
-			}
-			++idx;
 		}
 	}
 }
-- 
1.9.1

