**Next message:**Namhyung Kim: "Re: [PATCH 02/17] perf hists: Resort hist entries with hierarchy"**Previous message:**Namhyung Kim: "Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view"**In reply to:**Nicolas Pitre: "Re: [RFC V2 2/2] sched: idle: IRQ based next prediction for idle period"**Next in thread:**Daniel Lezcano: "[RFC V2 1/2] irq: Add a framework to measure interrupt timings"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ]

On 01/20/2016 09:14 PM, Nicolas Pitre wrote:

On Wed, 20 Jan 2016, Daniel Lezcano wrote:

[...]

One more comment:

+ /*

+ * If the mean value is null, just ignore this wakeup

+ * source.

+ */

+ mean = stats_mean(&w->stats);

+ if (!mean)

+ continue;

+

+ variance = stats_variance(&w->stats, mean);

+ /*

+ * We want to check the last interval is:

+ *

+ * mean - stddev < interval < mean + stddev

+ *

+ * That simplifies to:

+ *

+ * -stddev < interval - mean < stddev

+ *

+ * abs(interval - mean) < stddev

+ *

+ * The standard deviation is the sqrt of the variance:

+ *

+ * abs(interval - mean) < sqrt(variance)

+ *

+ * and we want to prevent to do an sqrt, so we square

+ * the equation:

+ *

+ * (interval - mean)^2 < variance

+ *

+ * So if the latest value of the stats complies with

+ * this condition, then the wakeup source is

+ * considered predictable and can be used to predict

+ * the next event.

+ */

+ interval = w->stats.values[w->stats.w_ptr];

+ if ((u64)((interval - mean) * (interval - mean)) > variance)

+ continue;

+

+ /*

+ * Let's compute the next event: the wakeup source is

+ * considered predictable, we add the average interval

+ * time added to the latest interruption event time.

+ */

+ next = ktime_add_us(w->timestamp, stats_mean(&w->stats));

You don't need to call stats_mean() again as you have it in the 'mean'

variable already.

Good point.

--

<http://www.linaro.org/> Linaro.org â Open source software for ARM SoCs

Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |

<http://twitter.com/#!/linaroorg> Twitter |

<http://www.linaro.org/linaro-blog/> Blog

**Next message:**Namhyung Kim: "Re: [PATCH 02/17] perf hists: Resort hist entries with hierarchy"**Previous message:**Namhyung Kim: "Re: [PATCH 01/17] perf hists: Basic support of hierarchical report view"**In reply to:**Nicolas Pitre: "Re: [RFC V2 2/2] sched: idle: IRQ based next prediction for idle period"**Next in thread:**Daniel Lezcano: "[RFC V2 1/2] irq: Add a framework to measure interrupt timings"**Messages sorted by:**[ date ] [ thread ] [ subject ] [ author ]