Re: [Patch 5/6] statistics infrastructure

Martin Peschke
2006-05-30T11:36:03Z

Nikita Danilov wrote:
> Martin Peschke writes:
> > This patch adds statistics infrastructure as common code.
> >
>
> [...]
>
> > +
> > +static void statistic_add_util(struct statistic *stat, int cpu,
> > + s64 value, u64 incr)
> > +{
> > + struct statistic_entry_util *util = stat->pdata->ptrs[cpu];
> > + util->num += incr;
> > + util->acc += value * incr;
> > + if (unlikely(value < util->min))
> > + util->min = value;
> > + if (unlikely(value > util->max))
> > + util->max = value;
>
> One useful aggregate that can be calculated here is a standard
> deviation. Something like
>
> util->acc_sq += value * incr * value * incr; /* sum of squares */
>
> And in statistic_fdata_util() squared standard deviation is
>
> std_dev = util->acc_sq;
> /*
> * Difference of averaged square and squared average.
> */
> std_dev = do_div(std_dev, util->num) - whole * whole;
>
> > +}
>
> Nikita.

Excellent idea. I will add the standard deviation.

Thanks, Martin