All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Bristot de Oliveira <bristot@kernel.org>
To: Andreas Ziegler <br015@umbiko.net>, Steven Rostedt <rostedt@goodmis.org>
Cc: linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2 v2] tools/tracing/rtla: osnoise_hist: use total duration for average calculation
Date: Thu, 12 Jan 2023 15:32:36 +0100	[thread overview]
Message-ID: <fefd9ded-b9d8-3b01-de39-7ff147206c84@kernel.org> (raw)
In-Reply-To: <20230103103400.275566-2-br015@umbiko.net>

On 1/3/23 11:33, Andreas Ziegler wrote:
> Sampled durations must be weighted by observed quantity, to arrive at a correct
> average duration value.
> 
> Perform calculation of total duration by summing (duration * count).
> 
> Fixes: 829a6c0b5698 ("rtla/osnoise: Add the hist mode")
> Signed-off-by: Andreas Ziegler <br015@umbiko.net>

Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
-- Daniel

> ---
> Changes v1 -> v2:
>  - add 'Fixes' line (Daniel)
> 
>  tools/tracing/rtla/src/osnoise_hist.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c
> index 5d7ea479ac89..fe34452fc4ec 100644
> --- a/tools/tracing/rtla/src/osnoise_hist.c
> +++ b/tools/tracing/rtla/src/osnoise_hist.c
> @@ -121,6 +121,7 @@ static void osnoise_hist_update_multiple(struct osnoise_tool *tool, int cpu,
>  {
>  	struct osnoise_hist_params *params = tool->params;
>  	struct osnoise_hist_data *data = tool->data;
> +	unsigned long long total_duration;
>  	int entries = data->entries;
>  	int bucket;
>  	int *hist;
> @@ -131,10 +132,12 @@ static void osnoise_hist_update_multiple(struct osnoise_tool *tool, int cpu,
>  	if (data->bucket_size)
>  		bucket = duration / data->bucket_size;
>  
> +	total_duration = duration * count;
> +
>  	hist = data->hist[cpu].samples;
>  	data->hist[cpu].count += count;
>  	update_min(&data->hist[cpu].min_sample, &duration);
> -	update_sum(&data->hist[cpu].sum_sample, &duration);
> +	update_sum(&data->hist[cpu].sum_sample, &total_duration);
>  	update_max(&data->hist[cpu].max_sample, &duration);
>  
>  	if (bucket < entries)


  reply	other threads:[~2023-01-12 14:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-24 12:39 rtla osnoise hist: average duration is always zero Andreas Ziegler
2022-12-24 21:17 ` Slade Watkins
2022-12-26 11:50   ` Andreas Ziegler
2022-12-28 15:25 ` Daniel Bristot de Oliveira
2023-01-03 10:33   ` [PATCH 0/2 v2] rtla osnoise hist average calculation Andreas Ziegler
2023-01-03 10:33   ` [PATCH 1/2 v2] tools/tracing/rtla: osnoise_hist: use total duration for " Andreas Ziegler
2023-01-12 14:32     ` Daniel Bristot de Oliveira [this message]
2023-01-03 10:34   ` [PATCH 2/2 v2] tools/tracing/rtla: osnoise_hist: display average with two-digit precision Andreas Ziegler
2023-01-12 14:33     ` Daniel Bristot de Oliveira

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=fefd9ded-b9d8-3b01-de39-7ff147206c84@kernel.org \
    --to=bristot@kernel.org \
    --cc=br015@umbiko.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.