From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757985AbcATT5O (ORCPT ); Wed, 20 Jan 2016 14:57:14 -0500 Received: from mail-qg0-f44.google.com ([209.85.192.44]:36525 "EHLO mail-qg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751194AbcATT5L (ORCPT ); Wed, 20 Jan 2016 14:57:11 -0500 Date: Wed, 20 Jan 2016 14:57:07 -0500 (EST) From: Nicolas Pitre To: Peter Zijlstra cc: Daniel Lezcano , tglx@linutronix.de, rafael@kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, vincent.guittot@linaro.org Subject: Re: [RFC V2 2/2] sched: idle: IRQ based next prediction for idle period In-Reply-To: <20160120194006.GW6357@twins.programming.kicks-ass.net> Message-ID: References: <1453305636-22156-1-git-send-email-daniel.lezcano@linaro.org> <1453305636-22156-3-git-send-email-daniel.lezcano@linaro.org> <20160120194006.GW6357@twins.programming.kicks-ass.net> User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 20 Jan 2016, Peter Zijlstra wrote: > On Wed, Jan 20, 2016 at 05:00:33PM +0100, Daniel Lezcano wrote: > > +static inline u32 stats_mean(struct stats *s) > > +{ > > + /* > > + * gcc is smart enough to convert to a bits shift when the > > + * divisor is constant and multiple of 2^x. > > + * > > + * The number of values could have not reached STATS_NR_VALUES > > + * yet, but we can consider it acceptable as the situation is > > + * only at the beginning of the burst of irqs. > > + */ > > + return s->sum / STATS_NR_VALUES; > > +} > > Note that ->sum is u64, so you're very prone to truncation. It won't. It is the sum of u32 values, so the mean of those values can't exceed 32 bits. Nicolas