lkml.org 
[lkml]   [2014]   [Jun]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [for-next][PATCH 3/6] tracing: Only calculate stats of tracepoint benchmarks for 2^32 times
Date
Hi Steve,

On Fri, 06 Jun 2014 12:30:37 -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> When calculating the average and standard deviation, it is required that
> the count be less than UINT_MAX, otherwise the do_div() will get
> undefined results. After 2^32 counts of data, the average and standard
> deviation should pretty much be set anyway.

[SNIP]
> if (bm_cnt > 1) {
> /*
> * Apply Welford's method to calculate standard deviation:
> * s^2 = 1 / (n * (n-1)) * (n * \Sum (x_i)^2 - (\Sum x_i)^2)
> */
> stddev = (u64)bm_cnt * bm_totalsq - bm_total * bm_total;
> - do_div(stddev, bm_cnt);
> - do_div(stddev, bm_cnt - 1);
> + do_div(stddev, (u32)bm_cnt);
> + do_div(stddev, (u32)bm_cnt - 1);
> } else
> stddev = 0;

I also think that this if-else can go as it checks bm_cnt == 1 above.

Thanks,
Namhyung


\
 
 \ /
  Last update: 2014-06-10 08:01    [W:0.094 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site