[PATCH] cpuidle: fix bug in the pattern detector as reported by Frank Rowand

From: Arjan van de Ven
Date: Sat May 22 2010 - 12:29:29 EST


Frank Rowand found a bug in the new pattern detector code where
the average value was looked at before the sum of values got divided
by the number of samples.

Signed-off-by: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
CC: akpm@xxxxxxxxxxxxxxxxxxxx
CC: frank.rowand@xxxxxxxxxxx
---
drivers/cpuidle/governors/menu.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index f3d4783..52ff8aa 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -205,12 +205,12 @@ static void detect_repeating_patterns(struct menu_device *data)
/* first calculate average and standard deviation of the past */
for (i = 0; i < INTERVALS; i++)
avg += data->intervals[i];
+ avg = avg / INTERVALS;

/* if the avg is beyond the known next tick, it's worthless */
if (avg > data->expected_us)
return;

- avg = avg / INTERVALS;
for (i = 0; i < INTERVALS; i++)
stddev += (data->intervals[i] - avg) *
(data->intervals[i] - avg);
--
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/