Prev: MAINTAINERS: update for ARM/Gemini
Next: swapper fixes (Was: kernel panic on kill(0, SIGTERM) with PGID == 0)
From: Arjan van de Ven on 22 May 2010 01:30 On Fri, 21 May 2010 12:43:09 -0700 Andrew Morton <akpm(a)linux-foundation.org> wrote: > On Wed, 19 May 2010 12:51:50 -0700 > Frank Rowand <frank.rowand(a)am.sony.com> wrote: > > > Aplogies if this is a duplicate, my outgoing email seems to have not > > been working. > > > > On 05/09/10 16:04, Arjan van de Ven wrote: > > > > > +/* > > > + * Try detecting repeating patterns by keeping track of the last > > > 8 > > > + * intervals, and checking if the standard deviation of that set > > > + * of points is below a threshold. If it is... then use the > > > + * average of these 8 points as the estimated value. > > > + */ > > > +static void detect_repeating_patterns(struct menu_device *data) > > > +{ > > > + int i; > > > + uint64_t avg = 0; > > > + uint64_t stddev = 0; /* contains the square of the std > > > deviation */ + > > > + /* first calculate average and standard deviation of the > > > past */ > > > + for (i = 0; i < INTERVALS; i++) > > > + avg += data->intervals[i]; > > > + > > > + /* if the avg is beyond the known next tick, it's > > > worthless */ > > > + if (avg > data->expected_us) > > > + return; > > > + > > > > Should the following division by INTERVALS be moved up 6 lines to > > before "if (avg > data->expected_us)"? > > Quite possibly. yeah that's a bug; I'll make a patch to fix it > > > > + avg = avg / INTERVALS; > > > + for (i = 0; i < INTERVALS; i++) > > > + stddev += (data->intervals[i] - avg) * > > > + (data->intervals[i] - avg); > > > + > > > + stddev = stddev / INTERVALS; > > > + > > > + /* > > > + * now.. if stddev is small.. then assume we have a > > > + * repeating pattern and predict we keep doing this. > > > + */ > > > + > > > + if (avg && stddev < STDDEV_THRESH) > > > + data->predicted_us = avg; > > > +} > > wakey wakey, Arjan. sorry, seems this email got lost in 400 "Suspend block API" emails ;( > > > Also, expected_us is 32-bit and predicted_us is 64-bit. Was that > rational? predicted holds intermediate results of some calculations.. and those overflow 32 bit... -- Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Arjan van de Ven on 22 May 2010 12:30 On Fri, 21 May 2010 12:43:09 -0700 Andrew Morton <akpm(a)linux-foundation.org> wrote: > > Should the following division by INTERVALS be moved up 6 lines to > > before "if (avg > data->expected_us)"? > > Quite possibly. From 7350a9007eee802eaa9e4c1878dd5a2ea4d6f7f9 Mon Sep 17 00:00:00 2001 From: Arjan van de Ven <arjan(a)linux.intel.com> Date: Sat, 22 May 2010 09:29:29 -0700 Subject: [PATCH] cpuidle: fix bug in the pattern detector as reported by Frank Rowand 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(a)linux.intel.com> CC: akpm(a)linux-foundation.org CC: frank.rowand(a)am.sony.com --- 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(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
First
|
Prev
|
Pages: 1 2 Prev: MAINTAINERS: update for ARM/Gemini Next: swapper fixes (Was: kernel panic on kill(0, SIGTERM) with PGID == 0) |