From: Juri Lelli <juri.lelli@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: fweisbec@gmail.com, mingo@redhat.com,
linux-kernel@vger.kernel.org,
Chase Douglas <chase.douglas@canonical.com>
Subject: Re: [PATCH 3/3] ftrace: fix stddev calculation
Date: Wed, 12 Jun 2013 11:34:56 +0200 [thread overview]
Message-ID: <51B840C0.7070608@gmail.com> (raw)
In-Reply-To: <1371006559.9844.250.camel@gandalf.local.home>
On 06/12/2013 05:09 AM, Steven Rostedt wrote:
> On Tue, 2013-06-11 at 11:08 +0200, Juri Lelli wrote:
>> When FUNCTION_GRAPH_TRACER is enabled, ftrace can profile kernel functions
>> and print basic statistics about them. Unfortunately, running stddev
>> calculation is wrong. This patch corrects it implementing Welford’s method:
>>
>> s^2 = 1 / (n * (n-1)) * (n * \Sum (x_i)^2 - (\Sum x_i)^2) .
>
> Looking at this further, we only need this fix. We don't need the other
> two patches, as that's just verifying the algorithm, and not something
> we need to do for run time tests. The run time tests is to test
> functionality, not calculations that can be done out of the kernel.
>
> Can you resubmit with just this change. And add the above line as a
> comment below.
>
Sure! No problem.
>>
>> Signed-off-by: Juri Lelli <juri.lelli@gmail.com>
>> Cc: Steven Rostedt <rostedt@goodmis.org>
>> Cc: Frederic Weisbecker <fweisbec@gmail.com>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> ---
>> kernel/trace/ftrace.c | 8 ++++++--
>> 1 file changed, 6 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
>> index 6caaa0e..073a328 100644
>> --- a/kernel/trace/ftrace.c
>> +++ b/kernel/trace/ftrace.c
>> @@ -593,13 +593,17 @@ void function_stat_calc(struct ftrace_profile *rec,
>> if (rec->counter <= 1)
>> *stddev = 0;
>> else {
>> - *stddev = rec->time_squared - rec->counter * (*avg) * (*avg);
>> + /*
>> + * Apply Welford's method.
>
> Welford's method is not well known. Please add:
>
> * s^2 = 1 / (n * (n-1)) * (n * \Sum (x_i)^2 - (\Sum x_i)^2)
>
Ok.
BTW, it is in general more interesting to look at distributions before
doing averages and std devs (one can miss multimodal distributions, etc.).
Is there any lightweight way to get single duration values of functions?
I mean, apart from parsing function graph trace off-line.
Thanks,
- Juri
>> + */
>> + *stddev = rec->counter * rec->time_squared -
>> + rec->time * rec->time;
>>
>> /*
>> * Divide only 1000 for ns^2 -> us^2 conversion.
>> * trace_print_graph_duration will divide 1000 again.
>> */
>> - do_div(*stddev, (rec->counter - 1) * 1000);
>> + do_div(*stddev, rec->counter * (rec->counter - 1) * 1000);
>> }
>> }
>>
>
>
prev parent reply other threads:[~2013-06-12 9:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-11 9:08 [PATCH 0/3] ftrace: fix stddev calculation and add a test for it Juri Lelli
2013-06-11 9:08 ` [PATCH 1/3] ftrace: refactor basis statistics calculation code Juri Lelli
2013-06-11 9:08 ` [PATCH 2/3] ftrace: test basic statistics calculation Juri Lelli
2013-06-12 0:00 ` Steven Rostedt
2013-06-11 9:08 ` [PATCH 3/3] ftrace: fix stddev calculation Juri Lelli
2013-06-12 3:09 ` Steven Rostedt
2013-06-12 9:34 ` Juri Lelli [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=51B840C0.7070608@gmail.com \
--to=juri.lelli@gmail.com \
--cc=chase.douglas@canonical.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox