lkml.org 
[lkml]   [2019]   [Mar]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] genirq/timings: Add array suffix computation code
Daniel,

On Tue, 26 Mar 2019, Daniel Lezcano wrote:
> >> +/*
> >> + * Exponential moving average computation
> >> + */
> >> +static int irq_timings_ema_new(s64 value, s64 ema_old)
> >
> > There is a mixed bag of s64/u64 all over this code. Please stay
> > consistent. We had enough sign confusion bugs in the past.
>
> Right.
>
> I have a question, ema_old and value will be always u64 type and the
> function irq_timings_ema_new() will return an u64 ...
>
> > value = (value - ema_old) * EMA_ALPHA_VAL;
> > return ema_old + value >> EMA_ALPHA_SHIFT;
>
> ... how can I deal with the operations above when value < ema_old ?
>
> Shall I use an intermediate s64 ?
>
> eg:
>
> s64 aux = (value - ema_old) * EMA_ALPHA_VAL;
> return ema_old + aux >> EMA_ALPHA_SHIFT;
> ?

That should work if ema_old is not ever having the topmost bit set :)

Thanks,

tglx

\
 
 \ /
  Last update: 2019-03-26 17:05    [W:0.040 / U:1.884 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site