lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 10 Jun 2014 12:12:30 -0400
From:	Steven Rostedt <rostedt@...dmis.org>
To:	Namhyung Kim <namhyung@...il.com>
Cc:	linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [for-next][PATCH 3/6] tracing: Only calculate stats of
 tracepoint benchmarks for 2^32 times

On Tue, 10 Jun 2014 09:42:06 -0400
Steven Rostedt <rostedt@...dmis.org> wrote:

> On Tue, 10 Jun 2014 14:17:54 +0900
> Namhyung Kim <namhyung@...il.com> wrote:
> 
> > Hi Steve,
> > 
> > On Fri, 06 Jun 2014 12:30:37 -0400, Steven Rostedt wrote:
> > > From: "Steven Rostedt (Red Hat)" <rostedt@...dmis.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.
> > 
> 
> I noticed this too, but just to keep gcc from complaining, I left it in.
> 

Oh, and you are talking about the entire if () else block. Yeah, I
thought about that as well, but I'm paranoid about doing a divide by
zero ;-)

It's code for testing purposes only. A fringe of the kernel base. Not a
hot path. Slowness isn't an issue here, but correctness is.

Thanks,

-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ