Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp465304rwb; Thu, 12 Jan 2023 08:15:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXvfXB0AkxBD46KYXcepMf3KnHYTRQCDxXFhr/UE/fUWwzmPMvVcPFVV97oaK+ywA8V/Tu6d X-Received: by 2002:a17:906:144a:b0:78d:f455:b4d5 with SMTP id q10-20020a170906144a00b0078df455b4d5mr65771529ejc.60.1673540159513; Thu, 12 Jan 2023 08:15:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673540159; cv=none; d=google.com; s=arc-20160816; b=FyOm+BtAoqFn4/wDWE1+bUNH5i2+ACeKQ8bkBgO1ubL+pSnwQP9kqFjByWGKa55RtN 5IJyk3O8VycxM28WyWbpACUPZEnMws76PmhT7g2qzznAyfXdV/RVRzCTWEnzeExCJovr StgGAq6Ekgd7T2RZawT8DSMWGgb9P8W8m76iuNrf4rN/IEw/ZUXlsAhPc0hmreCb9O57 AwutSiOCCFuS/TEERGGrwhBwgJfUIWbyfKhayqln6GlFET1xpbEJ6hygKUZ6eaxmTxF7 CGjrOnvJOugRwSDnHAqW59qlMq2BUHjHYCpNd1l7rVmx2i5jrWnSY8YxsocK8Cdf7CH7 JK8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=ooKSCF82wuR2P5+oRCYXdex1a9yl4g+9uqhx3WaSi40=; b=I+mlraJ/MkgcxQgYfbI6KSRvWvXreLAcHAKdwrO9dQfVixgrjTZKWMqbDYqX1QR4xH MlFktWqe4Nd0wFTkJwYi1jpnu/8ZAJAlVQzXIlJVYBY2sGaIQ1pI0Xt/oYLiiEyW7CSX /bAoyWWCvL1oYywy4oJua9Rc1j00KfUECs3JzPSgt678Ut71maw5oRs4Lr96fuzdP8R2 BXQCERIG4COKn1D/a2PLQDp5LUgeiSVDvSGykVKgfBdvN+nMmynUSG7QXJqkU02f2o2E p44cRVFqFLtq9JvljfJUKcX32qVzoMYtn8I2VSQ7KxkKk2ocVuJm5FhVjNBeNZA7UEWL pq3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="l5VKHPZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id vg13-20020a170907d30d00b0084cbcb3836esi16911618ejc.330.2023.01.12.08.15.47; Thu, 12 Jan 2023 08:15:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="l5VKHPZ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238170AbjALOoi (ORCPT + 50 others); Thu, 12 Jan 2023 09:44:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239711AbjALOnw (ORCPT ); Thu, 12 Jan 2023 09:43:52 -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 AB80563394; Thu, 12 Jan 2023 06:32:42 -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 49431B81E73; Thu, 12 Jan 2023 14:32:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB3A5C433EF; Thu, 12 Jan 2023 14:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673533959; bh=m9Ix+lLUkBPF9iqFxJS7VMgHIrgbScLcQu0xAEukD2E=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=l5VKHPZ/X/TaVa8tHeOb+/Qfm6x7qYKqMj8CXXGDtwzD1MJu9M0+6BWZM1fN1DDQi R9h7b73SQj8z8FczfVo9A18y4Cqkv8z5i9HxIOqq8K2ajT5MSMaWyuC0vG+S1LRHf7 C6hmt719moqh8h3YgJQFSCG/0EGcLOpHSLrMP6nOhDwA6BVNbqoUGDxmCFJ2F8jP0O 4CEaF31QBxaROftW+fAE5RLjxeBw3wAY3FBNPoXQI4IXqsVmN9nombJCY/67RpYjiH ZCPpXHq2iiusX3mxlaq0GO8thF+/Pf5k8/rEXhwXjmbqj0JGzIcNKJ0JBkDo6Rd1Sb lLUlFUIOxtasA== Message-ID: Date: Thu, 12 Jan 2023 15:32:36 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0 Subject: Re: [PATCH 1/2 v2] tools/tracing/rtla: osnoise_hist: use total duration for average calculation To: Andreas Ziegler , Steven Rostedt Cc: linux-trace-devel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230103103400.275566-2-br015@umbiko.net> Content-Language: en-US From: Daniel Bristot de Oliveira In-Reply-To: <20230103103400.275566-2-br015@umbiko.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Daniel Bristot de Oliveira -- 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)