lkml.org 
[lkml]   [2010]   [May]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] cpuidle: Add a repeating pattern detector to the menu governor
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)"?
> + 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;
> +}




\
 
 \ /
  Last update: 2010-05-19 21:53    [W:0.103 / U:0.288 seconds]
©2003-2014 Jasper Spaans. Advertise on this site