Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp463666lqd; Wed, 24 Apr 2024 07:38:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXrbaUXkM5J5l2GTDXdvuqiQoXkryRioiCJoDCJJYQskoBWT7m7jwL/J13T2DwclJ86hoFMD4c0V4nJ+fpnBjRMFYTBtufY2k6uwLyAew== X-Google-Smtp-Source: AGHT+IGB/jys0jMUeUWLBwD8YhRIyzPYeUykIv/lYlTl8aHsPV75/UCBVhE1WA1jITQS8LQpkqzo X-Received: by 2002:a17:906:4a0f:b0:a57:e2d0:5d6a with SMTP id w15-20020a1709064a0f00b00a57e2d05d6amr1905079eju.5.1713969524036; Wed, 24 Apr 2024 07:38:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713969524; cv=pass; d=google.com; s=arc-20160816; b=eA2IFKtp5twOGbWpwxbYrV4awzjFcy0H/peuwZbUv0hE28DZYPw3PZEaCQSjTFssss z1+pdFOvZdMww5kcHAK6xYrAhNGhRScZdJPDjKu35bb+euZsT+w2VgA4DM/hKlbGII6b ywIAGzF2LY3mWXeCl7rBzlQdctis5p1GfYSSWWoHGDhfc0wMDxneyzWhGkFyGSFltRNZ Ga8i9ntX6f/OKtWa8DrDxFWZJfLAqeQbY+qWiRtKLvDswXTcX2lLFiokhced2pxLea86 z2PI9GEBFyIi/bORBTYsxKNGIHPkZ7ViqQ0RNkii5+vstbjJSAML+0eRo/iUx55WgT48 FAyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YO+LEIJCBgRz5lpdv/BjsU5b0x540CQGRAZ+ZwyYt8c=; fh=dAFyoeb4mNleYvVLT04jG4V2YmdJAMhIAA3/3tuFxCc=; b=yt//AASrJYg6G07ghK7TY16GoybI04vGeCN4Ap8pg28NhAP6YYKlhl69uvB4V60JxM +G7mNSmxPO+LUNOUxCs7BC2cmF6bD+uewOU5hfMhSvrYu99w3bkJD8V7hfRcTWaQzDmw 6qZYBEmPkg4XwJzq7pL3lNQ5eaveos5iG4akFx4+h8DsiCdOvQxAvxh/gFRdO8kCrndm lNv39DUTil40wssA/dHAwFBprISH7HcyTTEAV5cWQrWrDlWnFK4Usy8E6hm7/zyxHv2S 3qyquwF5SUqQcpEANSiMwBOXt9jqEmJer3JRJcVquhEpvA3HdLvFCjyIxrl8pIxEjBM0 mVbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bo6rMHu0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-157092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hp12-20020a1709073e0c00b00a55b0380b6bsi4737277ejc.120.2024.04.24.07.38.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 07:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bo6rMHu0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-157092-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157092-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A4B11F20FDC for ; Wed, 24 Apr 2024 14:38:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4917915FD01; Wed, 24 Apr 2024 14:37:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bo6rMHu0" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5665215FA81; Wed, 24 Apr 2024 14:37:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969436; cv=none; b=mAJU2AioVyNT+UmuHzcj3+IbxpU/Gn7ByG5UJ6zc3Uo5Fg9kTqOBS7b7CdnWoIkR2B+7WI757QYv7JtoSNiDbObNP23jZrdkCrRNe2LF4mOz1O0UeHwLEHLoGtc7LmCbs1l3bJfw4uBXpTvXtD21B77PNVq82PmiRByM94gXxBc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969436; c=relaxed/simple; bh=390Eo1RZGQlHBzU/2csneSc6ReZsjy7ZuswNR9do5E0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uXONJ8NpuUgSo82npGhJ2fF8GBYzPmjPrbXV8Fs+khtrKHUJTbGLpyZlDYRyplyWD+GCAati6A8WTeaIcUw0S2KOJDpVZJk0A7O1yk/lnCNLeP0wl++JAgKFb+FRECzQt1B7kGzcohHTwwE/EyjeQsUHQ6Uh/2JHZbkxfQkTJ10= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bo6rMHu0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81A37C113CD; Wed, 24 Apr 2024 14:37:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969436; bh=390Eo1RZGQlHBzU/2csneSc6ReZsjy7ZuswNR9do5E0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bo6rMHu0ia3/o/kv8iDRWKIQM+VLXkshYEeUa232RmMw0oPix9CQc6li9wAgRlZfG JrOp5yipinSiZBBzm2iOO4O+MXt7ZVFejjcSIkKdgj/DidJ9XdXh8Y1lIraZlS/Tzt 4ad2nUQ6H6mPvKFvkcj/ToZseRPtaI9MdpTyGELqmxZyc7qGicsY7QuvKeuQYDfvr6 vqDkuwU02WTmI1XnRQKHbOoNKirgY5SkthDfASx/5YKTKiXV5MSeMC/FPtQ7VZvAqN 6idelyviDOD8HiP9tBF9j3dZXnYP88pN0HZuNByxw/i0eBWd+dcSwXYiMkvJ4geiP0 rvcG9lvG2JGIA== From: Daniel Bristot de Oliveira To: Daniel Bristot de Oliveira , Steven Rostedt , linux-trace-kernel@vger.kernel.org Cc: Jonathan Corbet , Juri Lelli , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/8] rtla/timerlat: Add a summary for hist mode Date: Wed, 24 Apr 2024 16:36:54 +0200 Message-ID: X-Mailer: git-send-email 2.44.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Like on rtla timerlat top, add an overall summary at the bottom of timerlat hist. For instance: # timerlat hist -c 0-1 -d 10s -E 20 # RTLA timerlat histogram # Time unit is microseconds (us) # Duration: 0 00:00:10 Index IRQ-000 Thr-000 IRQ-001 Thr-001 6 1 0 0 0 7 1 0 0 0 8 1 0 1 0 9 7 0 0 0 10 16 0 0 0 11 1 0 3 0 15 0 0 3 0 16 0 0 12 0 17 0 0 28 0 18 0 2 26 0 19 1 1 80 1 over: 9973 9998 9848 10000 count: 10001 10001 10001 10001 min: 6 18 8 19 avg: 185 204 95 113 max: 428 450 341 371 ALL: IRQ Thr count: 20002 20002 min: 6 18 avg: 140 159 max: 428 450 Suggested-by: Juri Lelli Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/timerlat_hist.c | 130 ++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 1 deletion(-) diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/src/timerlat_hist.c index 8bd51aab6513..b12c6b571dd4 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -401,8 +401,135 @@ timerlat_print_summary(struct timerlat_hist_params *params, trace_seq_reset(trace->seq); } +static void +timerlat_print_stats_all(struct timerlat_hist_params *params, + struct trace_instance *trace, + struct timerlat_hist_data *data) +{ + struct timerlat_hist_cpu *cpu_data; + struct timerlat_hist_cpu sum; + int cpu; + + if (params->no_summary) + return; + + memset(&sum, 0, sizeof(sum)); + sum.min_irq = ~0; + sum.min_thread = ~0; + sum.min_user = ~0; + + for (cpu = 0; cpu < data->nr_cpus; cpu++) { + if (params->cpus && !CPU_ISSET(cpu, ¶ms->monitored_cpus)) + continue; + + if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) + continue; + + cpu_data = &data->hist[cpu]; + + sum.irq_count += cpu_data->irq_count; + update_min(&sum.min_irq, &cpu_data->min_irq); + update_sum(&sum.sum_irq, &cpu_data->sum_irq); + update_max(&sum.max_irq, &cpu_data->max_irq); + + sum.thread_count += cpu_data->thread_count; + update_min(&sum.min_thread, &cpu_data->min_thread); + update_sum(&sum.sum_thread, &cpu_data->sum_thread); + update_max(&sum.max_thread, &cpu_data->max_thread); + + sum.user_count += cpu_data->user_count; + update_min(&sum.min_user, &cpu_data->min_user); + update_sum(&sum.sum_user, &cpu_data->sum_user); + update_max(&sum.max_user, &cpu_data->max_user); + } + + if (!params->no_index) + trace_seq_printf(trace->seq, "ALL: "); + + if (!params->no_irq) + trace_seq_printf(trace->seq, " IRQ"); + + if (!params->no_thread) + trace_seq_printf(trace->seq, " Thr"); + + if (params->user_hist) + trace_seq_printf(trace->seq, " Usr"); + + trace_seq_printf(trace->seq, "\n"); + + if (!params->no_index) + trace_seq_printf(trace->seq, "count:"); + + if (!params->no_irq) + trace_seq_printf(trace->seq, "%9d ", + sum.irq_count); + + if (!params->no_thread) + trace_seq_printf(trace->seq, "%9d ", + sum.thread_count); + + if (params->user_hist) + trace_seq_printf(trace->seq, "%9d ", + sum.user_count); + + trace_seq_printf(trace->seq, "\n"); + + if (!params->no_index) + trace_seq_printf(trace->seq, "min: "); + + if (!params->no_irq) + trace_seq_printf(trace->seq, "%9llu ", + sum.min_irq); + + if (!params->no_thread) + trace_seq_printf(trace->seq, "%9llu ", + sum.min_thread); + + if (params->user_hist) + trace_seq_printf(trace->seq, "%9llu ", + sum.min_user); + + trace_seq_printf(trace->seq, "\n"); + + if (!params->no_index) + trace_seq_printf(trace->seq, "avg: "); + + if (!params->no_irq) + trace_seq_printf(trace->seq, "%9llu ", + sum.sum_irq / sum.irq_count); + + if (!params->no_thread) + trace_seq_printf(trace->seq, "%9llu ", + sum.sum_thread / sum.thread_count); + + if (params->user_hist) + trace_seq_printf(trace->seq, "%9llu ", + sum.sum_user / sum.user_count); + + trace_seq_printf(trace->seq, "\n"); + + if (!params->no_index) + trace_seq_printf(trace->seq, "max: "); + + if (!params->no_irq) + trace_seq_printf(trace->seq, "%9llu ", + sum.max_irq); + + if (!params->no_thread) + trace_seq_printf(trace->seq, "%9llu ", + sum.max_thread); + + if (params->user_hist) + trace_seq_printf(trace->seq, "%9llu ", + sum.max_user); + + trace_seq_printf(trace->seq, "\n"); + trace_seq_do_printf(trace->seq); + trace_seq_reset(trace->seq); +} + /* - * timerlat_print_stats - print data for all CPUs + * timerlat_print_stats - print data for each CPUs */ static void timerlat_print_stats(struct timerlat_hist_params *params, struct osnoise_tool *tool) @@ -485,6 +612,7 @@ timerlat_print_stats(struct timerlat_hist_params *params, struct osnoise_tool *t trace_seq_reset(trace->seq); timerlat_print_summary(params, trace, data); + timerlat_print_stats_all(params, trace, data); } /* -- 2.44.0