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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <966ff66c-5ab9-23c4-7c23-01a802c20159@universe-factory.net>
Date:   Tue, 27 Mar 2018 16:51:49 +0200
From:   Matthias Schiffer <mschiffer@...verse-factory.net>
To:     Steven Rostedt <rostedt@...dmis.org>
Cc:     mingo@...hat.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ftrace: fix stddev calculation in function profiler
 (again)

On 03/26/2018 06:51 PM, Steven Rostedt wrote:
> On Sat, 24 Mar 2018 17:26:38 +0100
> Matthias Schiffer <mschiffer@...verse-factory.net> wrote:
> 
>> @@ -905,8 +898,20 @@ static void profile_graph_return(struct ftrace_graph_ret *trace)
>>  
>>  	rec = ftrace_find_profiled_func(stat, trace->func);
>>  	if (rec) {
>> +		unsigned long long avg, delta1, delta2;
>> +
>>  		rec->time += calltime;
>> -		rec->time_squared += calltime * calltime;
>> +
>> +		/* Apply Welford's method */
>> +		delta1 = calltime - rec->avg;
>> +
>> +		avg = rec->time;
>> +		do_div(avg, rec->counter);
> 
> Can you find a way not to do a divide in every function call?

I think the current method based on the sum of squares is the best we can
do without a divide for each sample. The completely bogus result

  nf_conntrack_proto_fini     50    373.523 us    7.470 us    3234315951 us

I mentioned in my commit message was caused by the second MIPS-specific
issue I mentioned in my last mail, so while this method may lead to
inaccurate results [1], and it is certainly not Welford's method, it might
be good enough in practice, and you can disregard my patch.

Matthias


[1]
http://jonisalonen.com/2013/deriving-welfords-method-for-computing-variance/


> 
> -- Steve
> 
>> +		rec->avg = avg;
>> +
>> +		delta2 = calltime - rec->avg;
>> +
>> +		rec->stddev += delta1 * delta2;
>>  	}
>>  
>>   out:
> 




Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ