From nobody Thu Sep 11 15:23:51 2025 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 1AE83C64EC4 for ; Sat, 18 Feb 2023 20:19:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229711AbjBRUTr (ORCPT ); Sat, 18 Feb 2023 15:19:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjBRUTi (ORCPT ); Sat, 18 Feb 2023 15:19:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80F161498F for ; Sat, 18 Feb 2023 12:19:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1FF81B80935 for ; Sat, 18 Feb 2023 20:19:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FE6BC433A4; Sat, 18 Feb 2023 20:19:33 +0000 (UTC) Received: from rostedt by gandalf.local.home with local (Exim 4.96) (envelope-from ) id 1pTTgC-000xso-1E; Sat, 18 Feb 2023 15:19:32 -0500 Message-ID: <20230218201932.196676123@goodmis.org> User-Agent: quilt/0.66 Date: Sat, 18 Feb 2023 15:18:23 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Andrew Morton , Andreas Ziegler , Daniel Bristot de Oliveira Subject: [for-next][PATCH 2/8] tools/tracing/rtla: osnoise_hist: use total duration for average calculation References: <20230218201821.938318263@goodmis.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andreas Ziegler Sampled durations must be weighted by observed quantity, to arrive at a cor= rect average duration value. Perform calculation of total duration by summing (duration * count). Link: https://lkml.kernel.org/r/20230103103400.275566-2-br015@umbiko.net Fixes: 829a6c0b5698 ("rtla/osnoise: Add the hist mode") Signed-off-by: Andreas Ziegler Acked-by: Daniel Bristot de Oliveira Signed-off-by: Steven Rostedt (Google) --- 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 =3D tool->params; struct osnoise_hist_data *data =3D tool->data; + unsigned long long total_duration; int entries =3D data->entries; int bucket; int *hist; @@ -131,10 +132,12 @@ static void osnoise_hist_update_multiple(struct osnoi= se_tool *tool, int cpu, if (data->bucket_size) bucket =3D duration / data->bucket_size; =20 + total_duration =3D duration * count; + hist =3D data->hist[cpu].samples; data->hist[cpu].count +=3D 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); =20 if (bucket < entries) --=20 2.39.1