From patchwork Tue Jan 3 10:33:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Ziegler X-Patchwork-Id: 13087352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FA26C54EBD for ; Tue, 3 Jan 2023 10:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237319AbjACKek (ORCPT ); Tue, 3 Jan 2023 05:34:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237226AbjACKeS (ORCPT ); Tue, 3 Jan 2023 05:34:18 -0500 Received: from serv15.avernis.de (serv15.avernis.de [IPv6:2a01:4f8:151:30a2::163]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80CA0FAF3; Tue, 3 Jan 2023 02:34:17 -0800 (PST) Received: from iago.. (unknown [95.91.249.42]) by serv15.avernis.de (Postfix) with ESMTPSA id 7A63CBDE03EE; Tue, 3 Jan 2023 11:34:15 +0100 (CET) From: Andreas Ziegler To: Daniel Bristot de Oliveira , Steven Rostedt Cc: linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Ziegler Subject: [PATCH 1/2 v2] tools/tracing/rtla: osnoise_hist: use total duration for average calculation Date: Tue, 3 Jan 2023 11:33:59 +0100 Message-Id: <20230103103400.275566-2-br015@umbiko.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.7 at serv15.avernis.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org 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 Acked-by: Daniel Bristot de Oliveira --- 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) From patchwork Tue Jan 3 10:34:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Ziegler X-Patchwork-Id: 13087351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E2D6C4708E for ; Tue, 3 Jan 2023 10:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237209AbjACKel (ORCPT ); Tue, 3 Jan 2023 05:34:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237128AbjACKeV (ORCPT ); Tue, 3 Jan 2023 05:34:21 -0500 Received: from serv15.avernis.de (serv15.avernis.de [IPv6:2a01:4f8:151:30a2::163]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB00AFADE; Tue, 3 Jan 2023 02:34:20 -0800 (PST) Received: from iago.. (unknown [95.91.249.42]) by serv15.avernis.de (Postfix) with ESMTPSA id 439FFBDE027B; Tue, 3 Jan 2023 11:34:17 +0100 (CET) From: Andreas Ziegler To: Daniel Bristot de Oliveira , Steven Rostedt Cc: linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Ziegler Subject: [PATCH 2/2 v2] tools/tracing/rtla: osnoise_hist: display average with two-digit precision Date: Tue, 3 Jan 2023 11:34:00 +0100 Message-Id: <20230103103400.275566-3-br015@umbiko.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.7 at serv15.avernis.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-trace-devel@vger.kernel.org Calculate average value in osnoise-hist summary with two-digit precision to avoid displaying too optimitic results. Signed-off-by: Andreas Ziegler Acked-by: Daniel Bristot de Oliveira --- Changes v1 -> v2: - output with two-digit precision instead of rounding (Daniel) tools/tracing/rtla/src/osnoise_hist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src/osnoise_hist.c index fe34452fc4ec..13e1233690bb 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -335,8 +335,8 @@ osnoise_print_summary(struct osnoise_hist_params *params, continue; if (data->hist[cpu].count) - trace_seq_printf(trace->seq, "%9llu ", - data->hist[cpu].sum_sample / data->hist[cpu].count); + trace_seq_printf(trace->seq, "%9.2f ", + ((double) data->hist[cpu].sum_sample) / data->hist[cpu].count); else trace_seq_printf(trace->seq, " - "); }