Thread (63 messages) 63 messages, 4 authors, 2016-01-22

Re: [RFC V2 2/2] sched: idle: IRQ based next prediction for idle period

From: Peter Zijlstra <peterz@infradead.org>
Date: 2016-01-20 19:34:56
Also in: lkml

On Wed, Jan 20, 2016 at 05:00:33PM +0100, Daniel Lezcano wrote:
+		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;
+
Cute :-)

You could consider putting a simple 3 point median filter in front of
stat_add() to get rid of the worst input noise.

(I know, improving all this was a point for later)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help