From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965130AbcAUNEL (ORCPT ); Thu, 21 Jan 2016 08:04:11 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:33977 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965066AbcAUNEI (ORCPT ); Thu, 21 Jan 2016 08:04:08 -0500 Subject: Re: [RFC V2 2/2] sched: idle: IRQ based next prediction for idle period To: Nicolas Pitre References: <1453305636-22156-1-git-send-email-daniel.lezcano@linaro.org> <1453305636-22156-6-git-send-email-daniel.lezcano@linaro.org> Cc: tglx@linutronix.de, peterz@infradead.org, rafael@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, vincent.guittot@linaro.org From: Daniel Lezcano Message-ID: <56A0D745.9060109@linaro.org> Date: Thu, 21 Jan 2016 14:04:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog