mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Matthias Schiffer <mschiffer@universe-factory.net>
Cc: mingo@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ftrace: fix stddev calculation in function profiler (again)
Date: Mon, 26 Mar 2018 12:51:31 -0400	[thread overview]
Message-ID: <20180326125131.15fba249@gandalf.local.home> (raw)
In-Reply-To: <f208c5c360f1e86327b0adbb879d61f4779e8ddd.1521908409.git.mschiffer@universe-factory.net>

On Sat, 24 Mar 2018 17:26:38 +0100
Matthias Schiffer <mschiffer@universe-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?

-- Steve

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

  parent reply	other threads:[~2018-03-26 16:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-24 16:26 Matthias Schiffer
2018-03-24 22:03 ` Matthias Schiffer
2018-03-25 17:09   ` Matthias Schiffer
2018-03-26 16:59     ` Steven Rostedt
2018-03-26 16:51 ` Steven Rostedt [this message]
2018-03-27 14:51   ` Matthias Schiffer
2018-03-27 15:14     ` Steven Rostedt

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=20180326125131.15fba249@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mschiffer@universe-factory.net \
    /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

all inboxes | Powered by JetHome®