From nobody Sat May 18 08:14:08 2024 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 D19B215ECF3; Wed, 24 Apr 2024 14:37:07 +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=1713969427; cv=none; b=oBg/GNpqGpzv4Ec5kMZB65KFWIKTl5krfQJA2sX8zoAy2ly35S0w2hokKgdopU+QRdaH7fX4oj38fLVmscernjJINDrA9/8m5io1/T69omzUKscsvwL73i1W41Pajn7TAX3+E8m1uvbfo7SfDVdErTL/PWwFkErhT4hCvjdPhqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969427; c=relaxed/simple; bh=k6zY+8OIqG3hvgbnxVfHVa3Ek+C1GSXe4a2L4RdgdEQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I4p/RcWZ1zCAN8/6K8+1ZXT88uax8P6zRTd8D19oH7cVci5oo0B60WzLqC8ppr1Jd0SEqbiDldnn7IJNhaHs+UMXFAb2SJv5Bdsgd8Ssvb/7Dn8W3hT+e6AFutJbXkDKji97u1mg1ZRX2UnFcjsYxXiaBFNPxqq+JmiOi+21sn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=h+F1XyJn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="h+F1XyJn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C08FC113CD; Wed, 24 Apr 2024 14:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969427; bh=k6zY+8OIqG3hvgbnxVfHVa3Ek+C1GSXe4a2L4RdgdEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h+F1XyJnBAnkc7gMGRYlCJFwpBgbkGE0SW36ugHTAwN/bG8lgwRhTmdfnTGyVdupS THlpUvl3MZVQJ0vnc+mjzkKT30t9vfj7vc3mHA7GZV4cLlGSBA5Nlk0lCGuzPynoMA lc28IawaXFrOl9rm1vOA68HUUEW4d2+F3FHLIGKiK6uLigTWvPvWiHnaw5pP0yHAoP IWPua28+RGj6IvY1W8UZ4sqzpofBmorsbPcnvYEkp+6W0C9FD4OuSkXbxRS/Qls8Px yhePsHLxoB30PP2WZJ2P7yhKuGejQZtyClOMmSbU3Lz6apmPfQ7fas5wNw0ZIuOSXH tC7Tv0Ju+AQqQ== 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, stable@vger.kernel.org Subject: [PATCH 1/8] rtla/timerlat: Simplify "no value" printing on top Date: Wed, 24 Apr 2024 16:36:50 +0200 Message-ID: <0a4d8085e7cd706733a5dc10a81ca38b82bd4992.1713968967.git.bristot@kernel.org> 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: quoted-printable Content-Type: text/plain; charset="utf-8" Instead of printing three times the same output, print it only once, reducing lines and being sure that all no values have the same length. It also fixes an extra '\n' when running the with kernel threads, like here: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D %< =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D Timer Latency 0 00:00:01 | IRQ Timer Latency (us) | Thread T= imer Latency (us) CPU COUNT | cur min avg max | cur m= in avg max 2 #0 | - - - - | 161 1= 61 161 161 3 #0 | - - - - | 161 1= 61 161 161 8 #1 | 54 54 54 54 | - = - - -'\n' ---------------|----------------------------------------|-----------------= ---------------------- ALL #1 e0 | 54 54 54 | 1= 61 161 161 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D %< =3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D This '\n' should have been removed with the user-space support that added another '\n' if not running with kernel threads. Cc: stable@vger.kernel.org Fixes: cdca4f4e5e8e ("rtla/timerlat_top: Add timerlat user-space support") Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/timerlat_top.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 8a3fa64319c6..2665e0bb5f1e 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -212,6 +212,8 @@ static void timerlat_top_header(struct osnoise_tool *to= p) trace_seq_printf(s, "\n"); } =20 +static const char *no_value =3D " -"; + /* * timerlat_top_print - prints the output of a given CPU */ @@ -239,10 +241,7 @@ static void timerlat_top_print(struct osnoise_tool *to= p, int cpu) trace_seq_printf(s, "%3d #%-9d |", cpu, cpu_data->irq_count); =20 if (!cpu_data->irq_count) { - trace_seq_printf(s, " - "); - trace_seq_printf(s, " - "); - trace_seq_printf(s, " - "); - trace_seq_printf(s, " - |"); + trace_seq_printf(s, "%s %s %s %s |", no_value, no_value, no_value, no_va= lue); } else { trace_seq_printf(s, "%9llu ", cpu_data->cur_irq / params->output_divisor= ); trace_seq_printf(s, "%9llu ", cpu_data->min_irq / params->output_divisor= ); @@ -251,10 +250,7 @@ static void timerlat_top_print(struct osnoise_tool *to= p, int cpu) } =20 if (!cpu_data->thread_count) { - trace_seq_printf(s, " - "); - trace_seq_printf(s, " - "); - trace_seq_printf(s, " - "); - trace_seq_printf(s, " -\n"); + trace_seq_printf(s, "%s %s %s %s", no_value, no_value, no_value, no_valu= e); } else { trace_seq_printf(s, "%9llu ", cpu_data->cur_thread / divisor); trace_seq_printf(s, "%9llu ", cpu_data->min_thread / divisor); @@ -271,10 +267,7 @@ static void timerlat_top_print(struct osnoise_tool *to= p, int cpu) trace_seq_printf(s, " |"); =20 if (!cpu_data->user_count) { - trace_seq_printf(s, " - "); - trace_seq_printf(s, " - "); - trace_seq_printf(s, " - "); - trace_seq_printf(s, " -\n"); + trace_seq_printf(s, "%s %s %s %s\n", no_value, no_value, no_value, no_va= lue); } else { trace_seq_printf(s, "%9llu ", cpu_data->cur_user / divisor); trace_seq_printf(s, "%9llu ", cpu_data->min_user / divisor); --=20 2.44.0 From nobody Sat May 18 08:14:08 2024 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 183A315EFCA; Wed, 24 Apr 2024 14:37:09 +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=1713969430; cv=none; b=Hs+vOc04G32XpcAd9Bjm6hivOAmx/U9zL1oebJ2ghgcQpHFESPZsxOEpQ7ZH211mFdHjClTkvO8ONB+78DSxNlh9Q5RIXl7hbtG9fshyrHPL3jK/edVM8vrwk0tuXJaZawBrvjJ3umtnr7cEkRqujZg1BwIRUsGTkb6bcdY84Fg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969430; c=relaxed/simple; bh=Y0PLM7xKWAYdtTO7V/Lt4sk7BQtoBLnoOXwBy12pTJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sJovcW29XZxBOjaHCHKOG2kMbppULirzdC4XG85RioiT68H/pd68DW9sxTrMLFJDa+arg9c7ndPQYdfhZ+eMxp4N5iU7f60F36+HkVaTrwyFmoVKUS+CP5hynuiS8Dq3AD2n3WxtEIi5+YEMVeiIMw++e/FkqBf9rsBA2FrnuCg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hOSLujcL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hOSLujcL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBBF6C32782; Wed, 24 Apr 2024 14:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969429; bh=Y0PLM7xKWAYdtTO7V/Lt4sk7BQtoBLnoOXwBy12pTJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hOSLujcLJgDonPQZE05jo62+gQLVWW7rVFbG0iNColA6YWkgBCYE4ULYzCrb0rPCj ILqO89ck/k9GS1BVHLUCeGwyS3BICo6tWmuYQd7DVdi5wLW4EOln915UNuHKGUf4cR bBRuBP97p7uAAm0kx8fcg5vfe9I6nXs6gAdecxzZQ1m3BVqXS1qvc/7Z1nS+oTB9TY NH9WXKQeA0e2TXE4QaY8RBB36v8c3aSiFI1rg/KTtXAn4oLc5D0HW0bpHihg3bl4H7 WGzYyXocincuCda2JVmX/CEj/GqO6c8F5zQwrTI/AHhJFYgO+FsR6E+Q/XTl+86e+0 oku/EZFMH7D2g== 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, stable@vger.kernel.org Subject: [PATCH 2/8] rtla/auto-analysis: Replace \t with spaces Date: Wed, 24 Apr 2024 16:36:51 +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: quoted-printable Content-Type: text/plain; charset="utf-8" When copying timerlat auto-analysis from a terminal to some web pages or chats, the \t are being replaced with a single ' ' or ' ', breaking the output. For example: ## CPU 3 hit stop tracing, analyzing it ## IRQ handler delay: 1.30 us (0.11 %) IRQ latency: 1.90 us Timerlat IRQ duration: 3.00 us (0.24 %) Blocking thread: 1223.16 us (99.00 %) insync:4048 1223.16 us IRQ interference 4.93 us (0.40 %) local_timer:236 4.93 us ------------------------------------------------------------------------ Thread latency: 1235.47 us (100%) Replace \t with spaces to avoid this problem. Cc: stable@vger.kernel.org Fixes: 27e348b221f6 ("rtla/timerlat: Add auto-analysis core") Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/timerlat_aa.c | 109 ++++++++++++++++----------- 1 file changed, 63 insertions(+), 46 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_aa.c b/tools/tracing/rtla/src/= timerlat_aa.c index 7093fd5333be..7bd80ee2a5b4 100644 --- a/tools/tracing/rtla/src/timerlat_aa.c +++ b/tools/tracing/rtla/src/timerlat_aa.c @@ -16,6 +16,9 @@ enum timelat_state { TIMERLAT_WAITING_THREAD, }; =20 +/* Used to fill spaces in the output */ +static const char *spaces =3D " = "; + #define MAX_COMM 24 =20 /* @@ -274,14 +277,17 @@ static int timerlat_aa_nmi_handler(struct trace_seq *= s, struct tep_record *recor taa_data->prev_irq_timstamp =3D start; =20 trace_seq_reset(taa_data->prev_irqs_seq); - trace_seq_printf(taa_data->prev_irqs_seq, "\t%24s \t\t\t%9.2f us\n", - "nmi", ns_to_usf(duration)); + trace_seq_printf(taa_data->prev_irqs_seq, " %24s %.*s %9.2f us\n", + "nmi", + 24, spaces, + ns_to_usf(duration)); return 0; } =20 taa_data->thread_nmi_sum +=3D duration; - trace_seq_printf(taa_data->nmi_seq, " %24s \t\t\t%9.2f us\n", - "nmi", ns_to_usf(duration)); + trace_seq_printf(taa_data->nmi_seq, " %24s %.*s %9.2f us\n", + "nmi", + 24, spaces, ns_to_usf(duration)); =20 return 0; } @@ -323,8 +329,10 @@ static int timerlat_aa_irq_handler(struct trace_seq *s= , struct tep_record *recor taa_data->prev_irq_timstamp =3D start; =20 trace_seq_reset(taa_data->prev_irqs_seq); - trace_seq_printf(taa_data->prev_irqs_seq, "\t%24s:%-3llu \t\t%9.2f us\n", - desc, vector, ns_to_usf(duration)); + trace_seq_printf(taa_data->prev_irqs_seq, " %24s:%-3llu %.*s %9.2f us\n= ", + desc, vector, + 15, spaces, + ns_to_usf(duration)); return 0; } =20 @@ -372,8 +380,10 @@ static int timerlat_aa_irq_handler(struct trace_seq *s= , struct tep_record *recor * IRQ interference. */ taa_data->thread_irq_sum +=3D duration; - trace_seq_printf(taa_data->irqs_seq, " %24s:%-3llu \t %9.2f us\n", - desc, vector, ns_to_usf(duration)); + trace_seq_printf(taa_data->irqs_seq, " %24s:%-3llu %.*s %9.2f us\n", + desc, vector, + 24, spaces, + ns_to_usf(duration)); =20 return 0; } @@ -408,8 +418,10 @@ static int timerlat_aa_softirq_handler(struct trace_se= q *s, struct tep_record *r =20 taa_data->thread_softirq_sum +=3D duration; =20 - trace_seq_printf(taa_data->softirqs_seq, "\t%24s:%-3llu \t %9.2f us\n", - softirq_name[vector], vector, ns_to_usf(duration)); + trace_seq_printf(taa_data->softirqs_seq, " %24s:%-3llu %.*s %9.2f us\n", + softirq_name[vector], vector, + 24, spaces, + ns_to_usf(duration)); return 0; } =20 @@ -452,8 +464,10 @@ static int timerlat_aa_thread_handler(struct trace_seq= *s, struct tep_record *re } else { taa_data->thread_thread_sum +=3D duration; =20 - trace_seq_printf(taa_data->threads_seq, "\t%24s:%-3llu \t\t%9.2f us\n", - comm, pid, ns_to_usf(duration)); + trace_seq_printf(taa_data->threads_seq, " %24s:%-12llu %.*s %9.2f us\n", + comm, pid, + 15, spaces, + ns_to_usf(duration)); } =20 return 0; @@ -482,7 +496,8 @@ static int timerlat_aa_stack_handler(struct trace_seq *= s, struct tep_record *rec function =3D tep_find_function(taa_ctx->tool->trace.tep, caller[i]); if (!function) break; - trace_seq_printf(taa_data->stack_seq, "\t\t-> %s\n", function); + trace_seq_printf(taa_data->stack_seq, " %.*s -> %s\n", + 14, spaces, function); } } return 0; @@ -568,23 +583,24 @@ static void timerlat_thread_analysis(struct timerlat_= aa_data *taa_data, int cpu, exp_irq_ts =3D taa_data->timer_irq_start_time - taa_data->timer_irq_start= _delay; if (exp_irq_ts < taa_data->prev_irq_timstamp + taa_data->prev_irq_duratio= n) { if (taa_data->prev_irq_timstamp < taa_data->timer_irq_start_time) - printf(" Previous IRQ interference: \t\t up to %9.2f us\n", - ns_to_usf(taa_data->prev_irq_duration)); + printf(" Previous IRQ interference: %.*s up to %9.2f us\n", + 16, spaces, + ns_to_usf(taa_data->prev_irq_duration)); } =20 /* * The delay that the IRQ suffered before starting. */ - printf(" IRQ handler delay: %16s %9.2f us (%.2f %%)\n", - (ns_to_usf(taa_data->timer_exit_from_idle) > 10) ? "(exit from idle)" : = "", - ns_to_usf(taa_data->timer_irq_start_delay), - ns_to_per(total, taa_data->timer_irq_start_delay)); + printf(" IRQ handler delay: %.*s %16s %9.2f us (%.2f %%)\n", 16, spaces, + (ns_to_usf(taa_data->timer_exit_from_idle) > 10) ? "(exit from idl= e)" : "", + ns_to_usf(taa_data->timer_irq_start_delay), + ns_to_per(total, taa_data->timer_irq_start_delay)); =20 /* * Timerlat IRQ. */ - printf(" IRQ latency: \t\t\t\t %9.2f us\n", - ns_to_usf(taa_data->tlat_irq_latency)); + printf(" IRQ latency: %.*s %9.2f us\n", 40, spaces, + ns_to_usf(taa_data->tlat_irq_latency)); =20 if (irq) { /* @@ -595,15 +611,16 @@ static void timerlat_thread_analysis(struct timerlat_= aa_data *taa_data, int cpu, * so it will be displayed, it is the key. */ printf(" Blocking thread:\n"); - printf(" %24s:%-9llu\n", - taa_data->run_thread_comm, taa_data->run_thread_pid); + printf(" %.*s %24s:%-9llu\n", 6, spaces, taa_data->run_thread_comm, + taa_data->run_thread_pid); } else { /* * The duration of the IRQ handler that handled the timerlat IRQ. */ - printf(" Timerlat IRQ duration: \t\t %9.2f us (%.2f %%)\n", - ns_to_usf(taa_data->timer_irq_duration), - ns_to_per(total, taa_data->timer_irq_duration)); + printf(" Timerlat IRQ duration: %.*s %9.2f us (%.2f %%)\n", + 30, spaces, + ns_to_usf(taa_data->timer_irq_duration), + ns_to_per(total, taa_data->timer_irq_duration)); =20 /* * The amount of time that the current thread postponed the scheduler. @@ -611,13 +628,13 @@ static void timerlat_thread_analysis(struct timerlat_= aa_data *taa_data, int cpu, * Recalling that it is net from NMI/IRQ/Softirq interference, so there * is no need to compute values here. */ - printf(" Blocking thread: \t\t\t %9.2f us (%.2f %%)\n", - ns_to_usf(taa_data->thread_blocking_duration), - ns_to_per(total, taa_data->thread_blocking_duration)); + printf(" Blocking thread: %.*s %9.2f us (%.2f %%)\n", 36, spaces, + ns_to_usf(taa_data->thread_blocking_duration), + ns_to_per(total, taa_data->thread_blocking_duration)); =20 - printf(" %24s:%-9llu %9.2f us\n", - taa_data->run_thread_comm, taa_data->run_thread_pid, - ns_to_usf(taa_data->thread_blocking_duration)); + printf(" %.*s %24s:%-9llu %.*s %9.2f us\n", 6, spaces, + taa_data->run_thread_comm, taa_data->run_thread_pid, + 12, spaces, ns_to_usf(taa_data->thread_blocking_duration)); } =20 /* @@ -629,9 +646,9 @@ static void timerlat_thread_analysis(struct timerlat_aa= _data *taa_data, int cpu, * NMIs can happen during the IRQ, so they are always possible. */ if (taa_data->thread_nmi_sum) - printf(" NMI interference \t\t\t %9.2f us (%.2f %%)\n", - ns_to_usf(taa_data->thread_nmi_sum), - ns_to_per(total, taa_data->thread_nmi_sum)); + printf(" NMI interference %.*s %9.2f us (%.2f %%)\n", 36, spaces, + ns_to_usf(taa_data->thread_nmi_sum), + ns_to_per(total, taa_data->thread_nmi_sum)); =20 /* * If it is an IRQ latency, the other factors can be skipped. @@ -643,9 +660,9 @@ static void timerlat_thread_analysis(struct timerlat_aa= _data *taa_data, int cpu, * Prints the interference caused by IRQs to the thread latency. */ if (taa_data->thread_irq_sum) { - printf(" IRQ interference \t\t\t %9.2f us (%.2f %%)\n", - ns_to_usf(taa_data->thread_irq_sum), - ns_to_per(total, taa_data->thread_irq_sum)); + printf(" IRQ interference %.*s %9.2f us (%.2f %%)\n", 36, spaces, + ns_to_usf(taa_data->thread_irq_sum), + ns_to_per(total, taa_data->thread_irq_sum)); =20 trace_seq_do_printf(taa_data->irqs_seq); } @@ -654,9 +671,9 @@ static void timerlat_thread_analysis(struct timerlat_aa= _data *taa_data, int cpu, * Prints the interference caused by Softirqs to the thread latency. */ if (taa_data->thread_softirq_sum) { - printf(" Softirq interference \t\t\t %9.2f us (%.2f %%)\n", - ns_to_usf(taa_data->thread_softirq_sum), - ns_to_per(total, taa_data->thread_softirq_sum)); + printf(" Softirq interference %.*s %9.2f us (%.2f %%)\n", 32, spaces, + ns_to_usf(taa_data->thread_softirq_sum), + ns_to_per(total, taa_data->thread_softirq_sum)); =20 trace_seq_do_printf(taa_data->softirqs_seq); } @@ -670,9 +687,9 @@ static void timerlat_thread_analysis(struct timerlat_aa= _data *taa_data, int cpu, * timer handling latency. */ if (taa_data->thread_thread_sum) { - printf(" Thread interference \t\t\t %9.2f us (%.2f %%)\n", - ns_to_usf(taa_data->thread_thread_sum), - ns_to_per(total, taa_data->thread_thread_sum)); + printf(" Thread interference %.*s %9.2f us (%.2f %%)\n", 33, spaces, + ns_to_usf(taa_data->thread_thread_sum), + ns_to_per(total, taa_data->thread_thread_sum)); =20 trace_seq_do_printf(taa_data->threads_seq); } @@ -682,8 +699,8 @@ static void timerlat_thread_analysis(struct timerlat_aa= _data *taa_data, int cpu, */ print_total: printf("-----------------------------------------------------------------= -------\n"); - printf(" %s latency: \t\t\t %9.2f us (100%%)\n", irq ? "IRQ" : "Thread", - ns_to_usf(total)); + printf(" %s latency: %.*s %9.2f us (100%%)\n", irq ? " IRQ" : "Thread", + 37, spaces, ns_to_usf(total)); } =20 static int timerlat_auto_analysis_collect_trace(struct timerlat_aa_context= *taa_ctx) --=20 2.44.0 From nobody Sat May 18 08:14:08 2024 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 347B815F314; Wed, 24 Apr 2024 14:37:11 +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=1713969432; cv=none; b=ukeZU7YCOKdgHwHMGZyX6pTDoLYFRWCaZmsYos6OlL147/RWEMc/TwZoKox0GE4qhUBySgvzHva4j5Ld6miMeEj8WbxA7KH5xFF+roldpg/RsAcdehgd8afoxsxZ4T6+bMmmeuUJX4y3Veqan+QvXhj7qc8Kq4b1vLoyVI9Y3Ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969432; c=relaxed/simple; bh=j0YRjq89mh1z9ilQ9W1YlxmSrjLRKNllnP5X8Z2EVek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=p6WqfMsH2P25xxc/lKKx78c59SiGvF4ULPH1UgYpNciNbybs1dfzLVrYem1Etx64V3+Wk1Z8d9FXFfqPuPLozrYQA0bJLlpMzWA2YA7H25GTtjoh00q3MYTeEg4/f4576ejcemMFWDs5s6qo2l+Xz5puBk0IiwgvXx/xZPqW7UU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cb/Nprvb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cb/Nprvb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26894C113CD; Wed, 24 Apr 2024 14:37:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969431; bh=j0YRjq89mh1z9ilQ9W1YlxmSrjLRKNllnP5X8Z2EVek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cb/NprvbwxGw0UkgQem5u9klDFeieqidScTiMeDYEyTMHs4YiHTfTAUPRaQaszgvx s/NQWo7A5bsWjTEr4qYdilBDBEZuL4yCG0qVqW/cjnY+wH9AR/dSpVwJp5Cl3j26rk kdvP3phGObMsa4uOTf7b0axS+zYzzEjxoMJDHocgcVOW/+6UWhj1E8A93D/wVm1nnS Ft4DGcepyio90rmM+PjC9WwOiM/om2FFDZwy+WwN1kLwUTbEvjxWpdmCEejnSo9uLL P65qWYFctca3Dc8s1DckNs1+OkyAEanZfDq2h8gNd5mGqRBfIQIKuEZnszXCdQYQ7Y 6S5QwvSlYWUQQ== 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 3/8] rtla/timerlat: Use pretty formatting only on interactive tty Date: Wed, 24 Apr 2024 16:36:52 +0200 Message-ID: <8288e1544ceab21557d5dda93a0f00339497c649.1713968967.git.bristot@kernel.org> 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: quoted-printable Content-Type: text/plain; charset="utf-8" timerlat top does some background/font color formatting. While useful on terminal, it breaks the output on other formats. For example, when piping the output for pastebin tools, the format strings are printed as characters. For instance: [2;37;40m Timer Latency = [0;0;0m 0 00:00:01 | IRQ Timer Latency (us) | Thread = Timer Latency (us) [2;30;47mCPU COUNT | cur min avg max | c= ur min avg max[0;0;0m 0 #1013 | 1 0 1 54 | 5 = 2 4 57 1 #1013 | 3 0 1 10 | 6 = 2 4 15 To avoid this problem, do the formatting only if running on a tty, and in !quiet mode. Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/timerlat_top.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 2665e0bb5f1e..c9cf90ed4e6d 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -44,6 +44,7 @@ struct timerlat_top_params { int hk_cpus; int user_top; int user_workload; + int pretty_output; cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; @@ -179,19 +180,22 @@ timerlat_top_handler(struct trace_seq *s, struct tep_= record *record, /* * timerlat_top_header - print the header of the tool output */ -static void timerlat_top_header(struct osnoise_tool *top) +static void timerlat_top_header(struct timerlat_top_params *params, struct= osnoise_tool *top) { - struct timerlat_top_params *params =3D top->params; struct trace_seq *s =3D top->trace.seq; char duration[26]; =20 get_duration(top->start_time, duration, sizeof(duration)); =20 - trace_seq_printf(s, "\033[2;37;40m"); + if (params->pretty_output) + trace_seq_printf(s, "\033[2;37;40m"); + trace_seq_printf(s, " Timer Latency = "); if (params->user_top) trace_seq_printf(s, " "); - trace_seq_printf(s, "\033[0;0;0m"); + + if (params->pretty_output) + trace_seq_printf(s, "\033[0;0;0m"); trace_seq_printf(s, "\n"); =20 trace_seq_printf(s, "%-6s | IRQ Timer Latency (%s) | = Thread Timer Latency (%s)", duration, @@ -204,11 +208,15 @@ static void timerlat_top_header(struct osnoise_tool *= top) } =20 trace_seq_printf(s, "\n"); - trace_seq_printf(s, "\033[2;30;47m"); + if (params->pretty_output) + trace_seq_printf(s, "\033[2;30;47m"); + trace_seq_printf(s, "CPU COUNT | cur min avg = max | cur min avg max"); if (params->user_top) trace_seq_printf(s, " | cur min avg max"); - trace_seq_printf(s, "\033[0;0;0m"); + + if (params->pretty_output) + trace_seq_printf(s, "\033[0;0;0m"); trace_seq_printf(s, "\n"); } =20 @@ -305,7 +313,7 @@ timerlat_print_stats(struct timerlat_top_params *params= , struct osnoise_tool *to if (!params->quiet) clear_terminal(trace->seq); =20 - timerlat_top_header(top); + timerlat_top_header(params, top); =20 for (i =3D 0; i < nr_cpus; i++) { if (params->cpus && !CPU_ISSET(i, ¶ms->monitored_cpus)) @@ -693,6 +701,9 @@ timerlat_top_apply_config(struct osnoise_tool *top, str= uct timerlat_top_params * } } =20 + if (isatty(1) && !params->quiet) + params->pretty_output =3D 1; + return 0; =20 out_err: --=20 2.44.0 From nobody Sat May 18 08:14:08 2024 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 80CE515F40B; Wed, 24 Apr 2024 14:37:14 +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=1713969434; cv=none; b=nnWb265tr+nVN1H7n9JKrXgJXwu3a+N2zI7rWTonn7J9YtfZnSK5AFSy75qif29rFAkJjLdp01q5j/6qotHVwGq8gPI3uMofvCD8MAgnBcTAPCBVFzMnbm4Sq7zt6DMBJdKNuC6YdwnC2fFbDKTqcOa1wNH5+IkjT9gDn4e4Q+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969434; c=relaxed/simple; bh=FeU1sJCZO1dwqnocdJMj/19AzVWP8TaVqxh+hJvWmD8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HF8cDndhoF2cw546LcnqIXkay20SAz68+EhUVCzUX5sg+n4EACICsUPwkgUsmKlPZJbMJncRGNxsemm3wyR+yO40zZX6vccXRdFqWKkGaIbH6+d0K7R2myK0ifHgOl4E4ZLyJs/5PfYVwUxj0ffJfIaRVY6iyn0z5HvTWt1JlCs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QLl61lUG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QLl61lUG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 576F1C2BBFC; Wed, 24 Apr 2024 14:37:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969434; bh=FeU1sJCZO1dwqnocdJMj/19AzVWP8TaVqxh+hJvWmD8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QLl61lUGilcDIJD5fbAQdUjX/n3ICrHAXqsw8YwYLiiyJQgf23JdKA038F7Hm6/8f hzQdr/aM9TYTfiX48zG5XorVt3XPvCA5sKRgLO4dC5ddadqi2C1e+0QnkLqUDDa0PD ccIXc2MgOLHEkUuWAJXqKHyKsHLrwNXJyppjKJqSPGz0nv6yYlw55+Khk/7jhi1RDW D0SR9sghO+wtbsfftyiW8a/NzcGAGCLMs1MiNKFQ9zUjqRZIemAXWUHt+eCOe1MYdn NXDE0agvyt9Q30e0ZCzFR+XHeL3Oh0ScazUT1aq/Rin7bDtQtCHUjXrl1DE4DlQRjT +im/XuqJwQpyQ== 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 4/8] rtla/timerlat: Add a summary for top mode Date: Wed, 24 Apr 2024 16:36:53 +0200 Message-ID: <5eb510d6faeb4ce745e09395196752df75a2dd1a.1713968967.git.bristot@kernel.org> 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: quoted-printable Content-Type: text/plain; charset="utf-8" While the per-cpu values are the results to take into consideration, the overall system values are also useful. Add a summary at the bottom of rtla timerlat top showing the overall results. For instance: Timer Latency 0 00:00:10 | IRQ Timer Latency (us) | Thread = Timer Latency (us) CPU COUNT | cur min avg max | cur = min avg max 0 #10003 | 113 19 150 441 | 134 = 35 170 459 1 #10003 | 63 8 99 462 | 84 = 15 119 481 2 #10003 | 3 2 89 396 | 21 = 8 108 414 3 #10002 | 206 11 210 394 | 223 = 21 228 415 ---------------|----------------------------------------|----------------= ----------------------- ALL #40011 e0 | 2 137 462 | = 8 156 481 Suggested-by: Juri Lelli Signed-off-by: Daniel Bristot de Oliveira --- tools/tracing/rtla/src/timerlat_top.c | 108 ++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index c9cf90ed4e6d..bdcf8ef8f815 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -119,6 +119,37 @@ static struct timerlat_top_data *timerlat_alloc_top(in= t nr_cpus) return NULL; } =20 +static void +timerlat_top_reset_sum(struct timerlat_top_cpu *summary) +{ + memset(summary, 0, sizeof(*summary)); + summary->min_irq =3D ~0; + summary->min_thread =3D ~0; + summary->min_user =3D ~0; +} + +static void +timerlat_top_update_sum(struct osnoise_tool *tool, int cpu, struct timerla= t_top_cpu *sum) +{ + struct timerlat_top_data *data =3D tool->data; + struct timerlat_top_cpu *cpu_data =3D &data->cpu_data[cpu]; + + sum->irq_count +=3D 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 +=3D 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 +=3D 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); +} + /* * timerlat_hist_update - record a new timerlat occurent on cpu, updating = data */ @@ -285,6 +316,77 @@ static void timerlat_top_print(struct osnoise_tool *to= p, int cpu) } } =20 +/* + * timerlat_top_print_sum - prints the summary output + */ +static void +timerlat_top_print_sum(struct osnoise_tool *top, struct timerlat_top_cpu *= summary) +{ + const char *split =3D "----------------------------------------"; + struct timerlat_top_params *params =3D top->params; + unsigned long long count =3D summary->irq_count; + int divisor =3D params->output_divisor; + struct trace_seq *s =3D top->trace.seq; + int e =3D 0; + + if (divisor =3D=3D 0) + return; + + /* + * Skip if no data is available: is this cpu offline? + */ + if (!summary->irq_count && !summary->thread_count) + return; + + while (count > 999999) { + e++; + count /=3D 10; + } + + trace_seq_printf(s, "%.*s|%.*s|%.*s", 15, split, 40, split, 39, split); + if (params->user_top) + trace_seq_printf(s, "-|%.*s", 39, split); + trace_seq_printf(s, "\n"); + + trace_seq_printf(s, "ALL #%-6llu e%d |", count, e); + + if (!summary->irq_count) { + trace_seq_printf(s, " %s %s %s |", no_value, no_value, no_value= ); + } else { + trace_seq_printf(s, " "); + trace_seq_printf(s, "%9llu ", summary->min_irq / params->output_divisor); + trace_seq_printf(s, "%9llu ", (summary->sum_irq / summary->irq_count) / = divisor); + trace_seq_printf(s, "%9llu |", summary->max_irq / divisor); + } + + if (!summary->thread_count) { + trace_seq_printf(s, "%s %s %s %s", no_value, no_value, no_value, no_valu= e); + } else { + trace_seq_printf(s, " "); + trace_seq_printf(s, "%9llu ", summary->min_thread / divisor); + trace_seq_printf(s, "%9llu ", + (summary->sum_thread / summary->thread_count) / divisor); + trace_seq_printf(s, "%9llu", summary->max_thread / divisor); + } + + if (!params->user_top) { + trace_seq_printf(s, "\n"); + return; + } + + trace_seq_printf(s, " |"); + + if (!summary->user_count) { + trace_seq_printf(s, " %s %s %s |", no_value, no_value, no_value= ); + } else { + trace_seq_printf(s, " "); + trace_seq_printf(s, "%9llu ", summary->min_user / divisor); + trace_seq_printf(s, "%9llu ", + (summary->sum_user / summary->user_count) / divisor); + trace_seq_printf(s, "%9llu\n", summary->max_user / divisor); + } +} + /* * clear_terminal - clears the output terminal */ @@ -301,6 +403,7 @@ static void timerlat_print_stats(struct timerlat_top_params *params, struct osnoise_to= ol *top) { struct trace_instance *trace =3D &top->trace; + struct timerlat_top_cpu summary; static int nr_cpus =3D -1; int i; =20 @@ -313,14 +416,19 @@ timerlat_print_stats(struct timerlat_top_params *para= ms, struct osnoise_tool *to if (!params->quiet) clear_terminal(trace->seq); =20 + timerlat_top_reset_sum(&summary); + timerlat_top_header(params, top); =20 for (i =3D 0; i < nr_cpus; i++) { if (params->cpus && !CPU_ISSET(i, ¶ms->monitored_cpus)) continue; timerlat_top_print(top, i); + timerlat_top_update_sum(top, i, &summary); } =20 + timerlat_top_print_sum(top, &summary); + trace_seq_do_printf(trace->seq); trace_seq_reset(trace->seq); } --=20 2.44.0 From nobody Sat May 18 08:14:08 2024 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bo6rMHu0" 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: quoted-printable Content-Type: text/plain; charset="utf-8" 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/sr= c/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 *p= arams, trace_seq_reset(trace->seq); } =20 +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 =3D ~0; + sum.min_thread =3D ~0; + sum.min_user =3D ~0; + + for (cpu =3D 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 =3D &data->hist[cpu]; + + sum.irq_count +=3D 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 +=3D 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 +=3D 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_t= ool *tool) @@ -485,6 +612,7 @@ timerlat_print_stats(struct timerlat_hist_params *param= s, struct osnoise_tool *t trace_seq_reset(trace->seq); =20 timerlat_print_summary(params, trace, data); + timerlat_print_stats_all(params, trace, data); } =20 /* --=20 2.44.0 From nobody Sat May 18 08:14:08 2024 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 264DD15ECCE; Wed, 24 Apr 2024 14:37:19 +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=1713969439; cv=none; b=eKHunq+aVfMyS3AaBCinUg0+e5sS5abS6bZN7FmTFsCcBbZ64h88ob7Vjp8yn1UNxt81dXhhCG2dv6PpsPp9RZq60s5BqkCBNOBPKLMG9aS0ohwxMJsfx6ap0Ze7BkAqPOUc6R0iC4CF7FizWFZHEt/uTx6O+UvVzie1fuc3BKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969439; c=relaxed/simple; bh=Ir4Y2qQm8lE4tORnhv0WH6e3Vusi/T6CAiMS9Ua2YVI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ODYaBMcit/GQ2TorTEuA+qh85OBkZiTtBr5SUTlWAfr6HL9GoiteXv++aRbqdd1wV6bvlit84dx6MSxDaAiWD4c81SigdwDxeDzSqozxNYOYXfnzjEG/XJkXusJNQewqzfjh3I/Gj2F2gcnWFIHIeStlGTqt/YjuFfSQ5I5WMAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WPduaNxl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WPduaNxl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD887C32783; Wed, 24 Apr 2024 14:37:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969439; bh=Ir4Y2qQm8lE4tORnhv0WH6e3Vusi/T6CAiMS9Ua2YVI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WPduaNxlsWw+gbO4TCsmKAxskVQ5NtL5UV2hKOCknxa9/eR+avEhyx6msHxQBB6Hp RI7CEVH44EEmXa0waar4emVcTve+sGfCJoSzZhSPYJ1gHz8ika9WpbYG+7IQbxiUdS nFs8drsK/rhkZ0G1yH9gq/1IX3EnTwKHJMrzAC9vFIAuDWq3yPpIOKGRrKQh0374lt CjuOfPUonAVEvnDCRjWO7Kt/uJKkjlY3DykwjVBeWidGHjY86mhEp8PTO8hFpJKq6N Dv+ICtJHOfJQ38+sBiKYaZ+KqLNwbo/vvQPEcSCVO6R/N00uuP4mQjc0BrSaQGJE8x rPTbr1zxl6jlA== 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 6/8] rtla: Add the --warm-up option Date: Wed, 24 Apr 2024 16:36:55 +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: quoted-printable Content-Type: text/plain; charset="utf-8" On many cases, the results right after the startup are different from the rest of the execution, biasing the results. For example, on osnoise, the scheduler might take some time to adapt to the new busy-loop workload. Add the --warm-up option, adding a warm-up phase (in seconds) where the workload is set, but the results are discarded. Signed-off-by: Daniel Bristot de Oliveira --- Documentation/tools/rtla/common_options.rst | 4 ++ tools/tracing/rtla/src/osnoise_hist.c | 30 +++++++++++-- tools/tracing/rtla/src/osnoise_top.c | 29 +++++++++++- tools/tracing/rtla/src/timerlat_hist.c | 49 ++++++++++++++------- tools/tracing/rtla/src/timerlat_top.c | 47 ++++++++++++-------- 5 files changed, 119 insertions(+), 40 deletions(-) diff --git a/Documentation/tools/rtla/common_options.rst b/Documentation/to= ols/rtla/common_options.rst index aeb91ff3bd68..a96ea0ed662e 100644 --- a/Documentation/tools/rtla/common_options.rst +++ b/Documentation/tools/rtla/common_options.rst @@ -50,6 +50,10 @@ =20 Set a *cgroup* to the tracer's threads. If the **-C** option is pa= ssed without arguments, the tracer's thread will inherit **rtla**'s *cgroup= *. Otherwise, the threads will be placed on the *cgroup* passed to the opti= on. =20 +**--warm-up** *s* + + After starting the workload, let it run for *s* seconds before sta= rting collecting the data, allowing the system to warm-up. Statistical data= generated during warm-up is discarded. + **-h**, **--help** =20 Print help menu. diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index 01870d50942a..c6100ff46a7f 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -36,13 +36,13 @@ struct osnoise_hist_params { cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; - char no_header; char no_summary; char no_index; char with_zeros; int bucket_size; int entries; + int warmup; }; =20 struct osnoise_hist_cpu { @@ -438,7 +438,7 @@ static void osnoise_hist_usage(char *usage) " usage: rtla osnoise hist [-h] [-D] [-d s] [-a us] [-p us] [-r us] [-s= us] [-S us] \\", " [-T us] [-t[=3Dfile]] [-e sys[:event]] [--filter ] [--trigge= r ] \\", " [-c cpu-list] [-H cpu-list] [-P priority] [-b N] [-E N] [--no-header= ] [--no-summary] \\", - " [--no-index] [--with-zeros] [-C[=3Dcgroup_name]]", + " [--no-index] [--with-zeros] [-C[=3Dcgroup_name]] [--warm-up]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argumen= t in us sample is hit", @@ -468,6 +468,7 @@ static void osnoise_hist_usage(char *usage) " f:prio - use SCHED_FIFO with prio", " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime = and period", " in nanoseconds", + " --warm-up: let the workload run for s seconds before collecting d= ata", NULL, }; =20 @@ -531,13 +532,14 @@ static struct osnoise_hist_params {"with-zeros", no_argument, 0, '3'}, {"trigger", required_argument, 0, '4'}, {"filter", required_argument, 0, '5'}, + {"warm-up", required_argument, 0, '6'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5= :", + c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5= :6:", long_options, &option_index); =20 /* detect the end of the options. */ @@ -680,6 +682,9 @@ static struct osnoise_hist_params osnoise_hist_usage("--filter requires a previous -e\n"); } break; + case '6': + params->warmup =3D get_llong_from_str(optarg); + break; default: osnoise_hist_usage("Invalid option"); } @@ -899,6 +904,25 @@ int osnoise_hist_main(int argc, char *argv[]) trace_instance_start(&record->trace); trace_instance_start(trace); =20 + if (params->warmup > 0) { + debug_msg("Warming up for %d seconds\n", params->warmup); + sleep(params->warmup); + if (stop_tracing) + goto out_hist; + + /* + * Clean up the buffer. The osnoise workload do not run + * with tracing off to avoid creating a performance penalty + * when not needed. + */ + retval =3D tracefs_instance_file_write(trace->inst, "trace", ""); + if (retval < 0) { + debug_msg("Error cleaning up the buffer"); + goto out_hist; + } + + } + tool->start_time =3D time(NULL); osnoise_hist_set_signals(params); =20 diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 457360db0767..53a074c1222e 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -40,6 +40,7 @@ struct osnoise_top_params { int set_sched; int cgroup; int hk_cpus; + int warmup; cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; @@ -282,7 +283,7 @@ static void osnoise_top_usage(struct osnoise_top_params= *params, char *usage) static const char * const msg[] =3D { " [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\", " [-T us] [-t[=3Dfile]] [-e sys[:event]] [--filter ] [--trigge= r ] \\", - " [-c cpu-list] [-H cpu-list] [-P priority] [-C[=3Dcgroup_name]]", + " [-c cpu-list] [-H cpu-list] [-P priority] [-C[=3Dcgroup_name]] [--wa= rm-up s]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argumen= t in us sample is hit", @@ -307,6 +308,7 @@ static void osnoise_top_usage(struct osnoise_top_params= *params, char *usage) " f:prio - use SCHED_FIFO with prio", " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime = and period", " in nanoseconds", + " --warm-up s: let the workload run for s seconds before collecting= data", NULL, }; =20 @@ -381,13 +383,14 @@ struct osnoise_top_params *osnoise_top_parse_args(int= argc, char **argv) {"trace", optional_argument, 0, 't'}, {"trigger", required_argument, 0, '0'}, {"filter", required_argument, 0, '1'}, + {"warm-up", required_argument, 0, '2'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:", + c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:", long_options, &option_index); =20 /* Detect the end of the options. */ @@ -511,6 +514,9 @@ struct osnoise_top_params *osnoise_top_parse_args(int a= rgc, char **argv) osnoise_top_usage(params, "--filter requires a previous -e\n"); } break; + case '2': + params->warmup =3D get_llong_from_str(optarg); + break; default: osnoise_top_usage(params, "Invalid option"); } @@ -732,6 +738,25 @@ int osnoise_top_main(int argc, char **argv) trace_instance_start(&record->trace); trace_instance_start(trace); =20 + if (params->warmup > 0) { + debug_msg("Warming up for %d seconds\n", params->warmup); + sleep(params->warmup); + if (stop_tracing) + goto out_top; + + /* + * Clean up the buffer. The osnoise workload do not run + * with tracing off to avoid creating a performance penalty + * when not needed. + */ + retval =3D tracefs_instance_file_write(trace->inst, "trace", ""); + if (retval < 0) { + debug_msg("Error cleaning up the buffer"); + goto out_top; + } + + } + tool->start_time =3D time(NULL); osnoise_top_set_signals(params); =20 diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index b12c6b571dd4..da1c353bdac9 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -52,6 +52,7 @@ struct timerlat_hist_params { char with_zeros; int bucket_size; int entries; + int warmup; }; =20 struct timerlat_hist_cpu { @@ -628,6 +629,7 @@ static void timerlat_hist_usage(char *usage) " [-t[=3Dfile]] [-e sys[:event]] [--filter ] [--trigger = ] [-c cpu-list] [-H cpu-list]\\", " [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [= --no-summary] \\", " [--no-index] [--with-zeros] [--dma-latency us] [-C[=3Dcgroup_name]] = [--no-aa] [--dump-task] [-u]", + " [--warm-up s]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argumen= t in us latency is hit", @@ -664,6 +666,7 @@ static void timerlat_hist_usage(char *usage) " in nanoseconds", " -u/--user-threads: use rtla user-space threads instead of in-kernel = timerlat threads", " -U/--user-load: enable timerlat for user-defined user-space workload= ", + " --warm-up s: let the workload run for s seconds before collecting= data", NULL, }; =20 @@ -738,13 +741,14 @@ static struct timerlat_hist_params {"dma-latency", required_argument, 0, '8'}, {"no-aa", no_argument, 0, '9'}, {"dump-task", no_argument, 0, '\1'}, + {"warm-up", required_argument, 0, '\2'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:uU012345= 6:7:8:9\1", + c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:uU012345= 6:7:8:9\1\2:", long_options, &option_index); =20 /* detect the end of the options. */ @@ -913,6 +917,9 @@ static struct timerlat_hist_params case '\1': params->dump_tasks =3D 1; break; + case '\2': + params->warmup =3D get_llong_from_str(optarg); + break; default: timerlat_hist_usage("Invalid option"); } @@ -1167,22 +1174,6 @@ int timerlat_hist_main(int argc, char *argv[]) } } =20 - /* - * Start the tracers here, after having set all instances. - * - * Let the trace instance start first for the case of hitting a stop - * tracing while enabling other instances. The trace instance is the - * one with most valuable information. - */ - if (params->trace_output) - trace_instance_start(&record->trace); - if (!params->no_aa) - trace_instance_start(&aa->trace); - trace_instance_start(trace); - - tool->start_time =3D time(NULL); - timerlat_hist_set_signals(params); - if (params->user_workload) { /* rtla asked to stop */ params_u.should_run =3D 1; @@ -1202,6 +1193,29 @@ int timerlat_hist_main(int argc, char *argv[]) err_msg("Error creating timerlat user-space threads\n"); } =20 + if (params->warmup > 0) { + debug_msg("Warming up for %d seconds\n", params->warmup); + sleep(params->warmup); + if (stop_tracing) + goto out_hist; + } + + /* + * Start the tracers here, after having set all instances. + * + * Let the trace instance start first for the case of hitting a stop + * tracing while enabling other instances. The trace instance is the + * one with most valuable information. + */ + if (params->trace_output) + trace_instance_start(&record->trace); + if (!params->no_aa) + trace_instance_start(&aa->trace); + trace_instance_start(trace); + + tool->start_time =3D time(NULL); + timerlat_hist_set_signals(params); + while (!stop_tracing) { sleep(params->sleep_time); =20 @@ -1227,6 +1241,7 @@ int timerlat_hist_main(int argc, char *argv[]) } } } + if (params->user_workload && !params_u.stopped_running) { params_u.should_run =3D 0; sleep(1); diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index bdcf8ef8f815..410eb5174913 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -45,6 +45,7 @@ struct timerlat_top_params { int user_top; int user_workload; int pretty_output; + int warmup; cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; @@ -444,7 +445,7 @@ static void timerlat_top_usage(char *usage) "", " usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us]= [-i us] [-T us] [-s us] \\", " [[-t[=3Dfile]] [-e sys[:event]] [--filter ] [--trigger ] [-c cpu-list] [-H cpu-list]\\", - " [-P priority] [--dma-latency us] [--aa-only us] [-C[=3Dcgroup_name]]= [-u]", + " [-P priority] [--dma-latency us] [--aa-only us] [-C[=3Dcgroup_name]]= [-u] [--warm-up s]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argumen= t in us latency is hit", @@ -475,6 +476,7 @@ static void timerlat_top_usage(char *usage) " in nanoseconds", " -u/--user-threads: use rtla user-space threads instead of in-kernel = timerlat threads", " -U/--user-load: enable timerlat for user-defined user-space workload= ", + " --warm-up s: let the workload run for s seconds before collecting= data", NULL, }; =20 @@ -541,13 +543,14 @@ static struct timerlat_top_params {"no-aa", no_argument, 0, '3'}, {"dump-tasks", no_argument, 0, '4'}, {"aa-only", required_argument, 0, '5'}, + {"warm-up", required_argument, 0, '6'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:i:np:P:qs:t::T:uU0:1:2:345= :", + c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:i:np:P:qs:t::T:uU0:1:2:345= :6:", long_options, &option_index); =20 /* detect the end of the options. */ @@ -704,6 +707,9 @@ static struct timerlat_top_params case '4': params->dump_tasks =3D 1; break; + case '6': + params->warmup =3D get_llong_from_str(optarg); + break; default: timerlat_top_usage("Invalid option"); } @@ -971,22 +977,6 @@ int timerlat_top_main(int argc, char *argv[]) } } =20 - /* - * Start the tracers here, after having set all instances. - * - * Let the trace instance start first for the case of hitting a stop - * tracing while enabling other instances. The trace instance is the - * one with most valuable information. - */ - if (params->trace_output) - trace_instance_start(&record->trace); - if (!params->no_aa && aa !=3D top) - trace_instance_start(&aa->trace); - trace_instance_start(trace); - - top->start_time =3D time(NULL); - timerlat_top_set_signals(params); - if (params->user_workload) { /* rtla asked to stop */ params_u.should_run =3D 1; @@ -1006,6 +996,27 @@ int timerlat_top_main(int argc, char *argv[]) err_msg("Error creating timerlat user-space threads\n"); } =20 + if (params->warmup > 0) { + debug_msg("Warming up for %d seconds\n", params->warmup); + sleep(params->warmup); + } + + /* + * Start the tracers here, after having set all instances. + * + * Let the trace instance start first for the case of hitting a stop + * tracing while enabling other instances. The trace instance is the + * one with most valuable information. + */ + if (params->trace_output) + trace_instance_start(&record->trace); + if (!params->no_aa && aa !=3D top) + trace_instance_start(&aa->trace); + trace_instance_start(trace); + + top->start_time =3D time(NULL); + timerlat_top_set_signals(params); + while (!stop_tracing) { sleep(params->sleep_time); =20 --=20 2.44.0 From nobody Sat May 18 08:14:08 2024 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 A66E015ECD7; Wed, 24 Apr 2024 14:37:21 +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=1713969441; cv=none; b=QwCTQyY2S+zr+UqOwWwr3JC9nU9nTFuvqWjW90ohVEPT3ArmilWFw8kfdIn6wjyqsJMIYOiHK1uD7vmA+LaSy02lh9fhKBMpeTDnGQczWRSXO4H0dzfUJEM9m2+NNjBeZk6KkW47WaEvCwFF4f7ep4qzgxV8OJUV2vMKF859PrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969441; c=relaxed/simple; bh=1t/w49AxJlRcOalla//YJH6wuX5qWxc2smFyxx/3lVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EBeWGzG4MmI9eZ3zi+JdNAamQx1Vz+FRemmwTVhyo2GPnHLxhppts1nnWr6FMtxqZxWRFxWg//BHn3PeRG21cPCGaRJNRX5nTqvk3hj0QVBpzN4/zm8+tHNgJSN+FOKPW3b12g++mOEY92gVIOySwvY39aMeJ8iGrxSOgUZwQNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D7EI9iqT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="D7EI9iqT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74214C113CD; Wed, 24 Apr 2024 14:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969441; bh=1t/w49AxJlRcOalla//YJH6wuX5qWxc2smFyxx/3lVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D7EI9iqTc43RSyJ1rDeBTGMjDqA38ALBoRIwlqUUz5Kkxuv5jwGTq012rLEwLKsEU bhLr9n3VhJArc6x+bRFL4IL9w8GLXiijVc3L7cfR2F+xIMKESFSQ+1Ju3uDAvmAJNR KI32xYZ+ctiTYyVx//ZD5zSU5BYmoFTcWG2hGx3g7vlEg+iWoD+FcuAGX99gtP+UI2 NtswUmH6vNu7xvqbjWtVfIDdkyfG7Fq9Fqlzzq6v9T/z8bP9lGbIokgh5DGXeAjS3k LusioDgDUE4ihm9bBquT8ozDAGbU/4ORDpHMCuF+T7RAvE+cogIUNLLLl39/2K8r+K 1ZOhNgJojQ/JA== 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 7/8] rtla/timerlat: Make user-space threads the default Date: Wed, 24 Apr 2024 16:36:56 +0200 Message-ID: <9241d3089de4091b124f780ed832a0e6646cadaa.1713968967.git.bristot@kernel.org> 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: quoted-printable Content-Type: text/plain; charset="utf-8" After ther -u addition, most of the known users are setting it. And it makes sense, as it adds more information, and inherits the default setup for the threads - e.g., cgroups configs. Thus, if the user-space interface is available, enable -u. Otherwise, use the in-kernel thread. Add the -k option to allow the user to request kernel-threads. Signed-off-by: Daniel Bristot de Oliveira --- .../tools/rtla/common_timerlat_options.rst | 6 +++- tools/tracing/rtla/src/timerlat_hist.c | 31 +++++++++++++++++-- tools/tracing/rtla/src/timerlat_top.c | 31 +++++++++++++++++-- 3 files changed, 61 insertions(+), 7 deletions(-) diff --git a/Documentation/tools/rtla/common_timerlat_options.rst b/Documen= tation/tools/rtla/common_timerlat_options.rst index d3255ed70195..090700a6ae9f 100644 --- a/Documentation/tools/rtla/common_timerlat_options.rst +++ b/Documentation/tools/rtla/common_timerlat_options.rst @@ -27,12 +27,16 @@ *cyclictest* sets this value to *0* by default, use **--dma-latenc= y** *0* to have similar results. =20 +**-k**, **--kernel-threads** + + Use timerlat kernel-space threads, in contrast of **-u**. + **-u**, **--user-threads** =20 Set timerlat to run without a workload, and then dispatches user-s= pace workloads to wait on the timerlat_fd. Once the workload is awakes, it goes t= o sleep again adding so the measurement for the kernel-to-user and user-to-kerne= l to the tracer - output. + output. **--user-threads** will be used unless the user specify **= -k**. =20 **-U**, **--user-load** =20 diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index da1c353bdac9..6eb6e38d4a05 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -40,6 +40,7 @@ struct timerlat_hist_params { int no_aa; int dump_tasks; int user_workload; + int kernel_workload; int user_hist; cpu_set_t hk_cpu_set; struct sched_attr sched_param; @@ -628,7 +629,7 @@ static void timerlat_hist_usage(char *usage) " usage: [rtla] timerlat hist [-h] [-q] [-d s] [-D] [-n] [-a us] [-p us= ] [-i us] [-T us] [-s us] \\", " [-t[=3Dfile]] [-e sys[:event]] [--filter ] [--trigger = ] [-c cpu-list] [-H cpu-list]\\", " [-P priority] [-E N] [-b N] [--no-irq] [--no-thread] [--no-header] [= --no-summary] \\", - " [--no-index] [--with-zeros] [--dma-latency us] [-C[=3Dcgroup_name]] = [--no-aa] [--dump-task] [-u]", + " [--no-index] [--with-zeros] [--dma-latency us] [-C[=3Dcgroup_name]] = [--no-aa] [--dump-task] [-u|-k]", " [--warm-up s]", "", " -h/--help: print this menu", @@ -664,7 +665,8 @@ static void timerlat_hist_usage(char *usage) " f:prio - use SCHED_FIFO with prio", " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime = and period", " in nanoseconds", - " -u/--user-threads: use rtla user-space threads instead of in-kernel = timerlat threads", + " -u/--user-threads: use rtla user-space threads instead of kernel-spa= ce timerlat threads", + " -k/--kernel-threads: use timerlat kernel-space threads instead of rt= la user-space threads", " -U/--user-load: enable timerlat for user-defined user-space workload= ", " --warm-up s: let the workload run for s seconds before collecting= data", NULL, @@ -728,6 +730,7 @@ static struct timerlat_hist_params {"thread", required_argument, 0, 'T'}, {"trace", optional_argument, 0, 't'}, {"user-threads", no_argument, 0, 'u'}, + {"kernel-threads", no_argument, 0, 'k'}, {"user-load", no_argument, 0, 'U'}, {"event", required_argument, 0, 'e'}, {"no-irq", no_argument, 0, '0'}, @@ -748,7 +751,7 @@ static struct timerlat_hist_params /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:np:P:s:t::T:uU012345= 6:7:8:9\1\2:", + c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU01234= 56:7:8:9\1\2:", long_options, &option_index); =20 /* detect the end of the options. */ @@ -831,6 +834,9 @@ static struct timerlat_hist_params case 'i': params->stop_us =3D get_llong_from_str(optarg); break; + case 'k': + params->kernel_workload =3D 1; + break; case 'n': params->output_divisor =3D 1; break; @@ -942,6 +948,9 @@ static struct timerlat_hist_params if (!params->stop_us && !params->stop_total_us) params->no_aa =3D 1; =20 + if (params->kernel_workload && params->user_workload) + timerlat_hist_usage("--kernel-threads and --user-threads are mutually ex= clusive!"); + return params; } =20 @@ -1017,6 +1026,22 @@ timerlat_hist_apply_config(struct osnoise_tool *tool= , struct timerlat_hist_param auto_house_keeping(¶ms->monitored_cpus); } =20 + /* + * If the user did not specify a type of thread, try user-threads first. + * Fall back to kernel threads otherwise. + */ + if (!params->kernel_workload && !params->user_workload) { + retval =3D tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd"); + if (retval) { + debug_msg("User-space interface detected, setting user-threads\n"); + params->user_workload =3D 1; + params->user_hist =3D 1; + } else { + debug_msg("User-space interface not detected, setting kernel-threads\n"= ); + params->kernel_workload =3D 1; + } + } + if (params->user_hist) { retval =3D osnoise_set_workload(tool->context, 0); if (retval) { diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 410eb5174913..0acfefe151f7 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -44,6 +44,7 @@ struct timerlat_top_params { int hk_cpus; int user_top; int user_workload; + int kernel_workload; int pretty_output; int warmup; cpu_set_t hk_cpu_set; @@ -445,7 +446,7 @@ static void timerlat_top_usage(char *usage) "", " usage: rtla timerlat [top] [-h] [-q] [-a us] [-d s] [-D] [-n] [-p us]= [-i us] [-T us] [-s us] \\", " [[-t[=3Dfile]] [-e sys[:event]] [--filter ] [--trigger ] [-c cpu-list] [-H cpu-list]\\", - " [-P priority] [--dma-latency us] [--aa-only us] [-C[=3Dcgroup_name]]= [-u] [--warm-up s]", + " [-P priority] [--dma-latency us] [--aa-only us] [-C[=3Dcgroup_name]]= [-u|-k] [--warm-up s]", "", " -h/--help: print this menu", " -a/--auto: set automatic trace mode, stopping the session if argumen= t in us latency is hit", @@ -474,7 +475,8 @@ static void timerlat_top_usage(char *usage) " f:prio - use SCHED_FIFO with prio", " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime = and period", " in nanoseconds", - " -u/--user-threads: use rtla user-space threads instead of in-kernel = timerlat threads", + " -u/--user-threads: use rtla user-space threads instead of kernel-spa= ce timerlat threads", + " -k/--kernel-threads: use timerlat kernel-space threads instead of rt= la user-space threads", " -U/--user-load: enable timerlat for user-defined user-space workload= ", " --warm-up s: let the workload run for s seconds before collecting= data", NULL, @@ -536,6 +538,7 @@ static struct timerlat_top_params {"thread", required_argument, 0, 'T'}, {"trace", optional_argument, 0, 't'}, {"user-threads", no_argument, 0, 'u'}, + {"kernel-threads", no_argument, 0, 'k'}, {"user-load", no_argument, 0, 'U'}, {"trigger", required_argument, 0, '0'}, {"filter", required_argument, 0, '1'}, @@ -550,7 +553,7 @@ static struct timerlat_top_params /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:i:np:P:qs:t::T:uU0:1:2:345= :6:", + c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:34= 5:6:", long_options, &option_index); =20 /* detect the end of the options. */ @@ -635,6 +638,9 @@ static struct timerlat_top_params case 'i': params->stop_us =3D get_llong_from_str(optarg); break; + case 'k': + params->kernel_workload =3D true; + break; case 'n': params->output_divisor =3D 1; break; @@ -729,6 +735,9 @@ static struct timerlat_top_params if (params->no_aa && params->aa_only) timerlat_top_usage("--no-aa and --aa-only are mutually exclusive!"); =20 + if (params->kernel_workload && params->user_workload) + timerlat_top_usage("--kernel-threads and --user-threads are mutually exc= lusive!"); + return params; } =20 @@ -807,6 +816,22 @@ timerlat_top_apply_config(struct osnoise_tool *top, st= ruct timerlat_top_params * auto_house_keeping(¶ms->monitored_cpus); } =20 + /* + * If the user did not specify a type of thread, try user-threads first. + * Fall back to kernel threads otherwise. + */ + if (!params->kernel_workload && !params->user_workload) { + retval =3D tracefs_file_exists(NULL, "osnoise/per_cpu/cpu0/timerlat_fd"); + if (retval) { + debug_msg("User-space interface detected, setting user-threads\n"); + params->user_workload =3D 1; + params->user_top =3D 1; + } else { + debug_msg("User-space interface not detected, setting kernel-threads\n"= ); + params->kernel_workload =3D 1; + } + } + if (params->user_top) { retval =3D osnoise_set_workload(top->context, 0); if (retval) { --=20 2.44.0 From nobody Sat May 18 08:14:08 2024 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 7C5D8160885; Wed, 24 Apr 2024 14:37:23 +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=1713969443; cv=none; b=CLWVj/A5RLL0VwZAV/95wfhOcgJgFb202YjkIDDM0TlvMmPdwJN0BjUGUaN2Qtgz9yOsq4paIBHzITq6HwvvL/pynXg0r0i6cuhfxMQa8j1Z1TWJKOUrpuYM3vAka58g9NS+9RNfkbHec+uUzKnRYbCLtCG3xxBjTDHI/CnMSb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713969443; c=relaxed/simple; bh=PW/mKN9SsKQYfJubvo/JIUYxbAIyYneBGNWi3qCcTow=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EwDGnFp0+MzuTB5jdvqPJkW5BHi8LjcxGIBTapNWhfJH8HVP/0gDmCM4T0SC8pNGI4zfxFMcK0wEOj5z4VAFnbOOJYhuzI/B6gb3mvSJphNDgZ8TuqXFbgJSXP8smQmV2CYjEXJXzn998wLGrsEZRD6apkLuUgHJS2D37aD8TyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BPUDLJT3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BPUDLJT3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CBF6C2BBFC; Wed, 24 Apr 2024 14:37:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713969443; bh=PW/mKN9SsKQYfJubvo/JIUYxbAIyYneBGNWi3qCcTow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPUDLJT38CANyl6uS+s1jGahVWM31z9fmKVu4lCJCA+sF8M1qXGO9ur8w+zLEaIAa i4yIULeptP3FJfyp73jx7z9ysSWOSLdETgP90wMLtdZodb0jrcWwxFgH34qKu1hpy9 idvKtJ9XUFM7CR1qaaukFi/U/P+23VsrrZqk2dWw+sKZxXnzLrXCqdJ2C5Sb14B/Fu ZUCA0ND/2hPdTkKb64ZzRBhnwrIeX2Bf0fkp0c8yw3ucvMd0YWm8Zw8NL+EMLRXqbk hlcfJOWgUmjQOoRwDmW9PVe2fqxAY8yhB9GD5GxHuw9dDfPs0S2a+zk8DbkAOTJ/FP R2sZda5Kiwv5w== 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 8/8] rtla: Add --trace-buffer-size option Date: Wed, 24 Apr 2024 16:36:57 +0200 Message-ID: <0281bfbd3b3fed11a0150a8645a1f9941a423c7a.1713968967.git.bristot@kernel.org> 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: quoted-printable Content-Type: text/plain; charset="utf-8" Add the option allow the users to set a different buffer size for the trace. For example, in large systems, the user might be interested on reducing the trace buffer to avoid large tracing files. The buffer size is specified in kB, and it is only affecting the tracing instance. Signed-off-by: Daniel Bristot de Oliveira --- Documentation/tools/rtla/common_options.rst | 3 +++ tools/tracing/rtla/src/osnoise_hist.c | 13 ++++++++++++- tools/tracing/rtla/src/osnoise_top.c | 14 +++++++++++++- tools/tracing/rtla/src/timerlat_hist.c | 14 +++++++++++++- tools/tracing/rtla/src/timerlat_top.c | 14 +++++++++++++- tools/tracing/rtla/src/trace.c | 15 +++++++++++++++ tools/tracing/rtla/src/trace.h | 1 + 7 files changed, 70 insertions(+), 4 deletions(-) diff --git a/Documentation/tools/rtla/common_options.rst b/Documentation/to= ols/rtla/common_options.rst index a96ea0ed662e..7ac7b7581466 100644 --- a/Documentation/tools/rtla/common_options.rst +++ b/Documentation/tools/rtla/common_options.rst @@ -54,6 +54,9 @@ =20 After starting the workload, let it run for *s* seconds before sta= rting collecting the data, allowing the system to warm-up. Statistical data= generated during warm-up is discarded. =20 +**--trace-buffer-size** *kB* + Set the per-cpu trace buffer size in kB for the tracing output. + **-h**, **--help** =20 Print help menu. diff --git a/tools/tracing/rtla/src/osnoise_hist.c b/tools/tracing/rtla/src= /osnoise_hist.c index c6100ff46a7f..198a17a3ea2e 100644 --- a/tools/tracing/rtla/src/osnoise_hist.c +++ b/tools/tracing/rtla/src/osnoise_hist.c @@ -43,6 +43,7 @@ struct osnoise_hist_params { int bucket_size; int entries; int warmup; + int buffer_size; }; =20 struct osnoise_hist_cpu { @@ -469,6 +470,7 @@ static void osnoise_hist_usage(char *usage) " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime = and period", " in nanoseconds", " --warm-up: let the workload run for s seconds before collecting d= ata", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; =20 @@ -533,13 +535,14 @@ static struct osnoise_hist_params {"trigger", required_argument, 0, '4'}, {"filter", required_argument, 0, '5'}, {"warm-up", required_argument, 0, '6'}, + {"trace-buffer-size", required_argument, 0, '7'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5= :6:", + c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:p:P:r:s:S:t::T:01234:5= :6:7:", long_options, &option_index); =20 /* detect the end of the options. */ @@ -685,6 +688,9 @@ static struct osnoise_hist_params case '6': params->warmup =3D get_llong_from_str(optarg); break; + case '7': + params->buffer_size =3D get_llong_from_str(optarg); + break; default: osnoise_hist_usage("Invalid option"); } @@ -891,6 +897,11 @@ int osnoise_hist_main(int argc, char *argv[]) goto out_hist; } =20 + if (params->buffer_size > 0) { + retval =3D trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_hist; + } } =20 /* diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/= osnoise_top.c index 53a074c1222e..7e5aab22727d 100644 --- a/tools/tracing/rtla/src/osnoise_top.c +++ b/tools/tracing/rtla/src/osnoise_top.c @@ -41,6 +41,7 @@ struct osnoise_top_params { int cgroup; int hk_cpus; int warmup; + int buffer_size; cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; @@ -309,6 +310,7 @@ static void osnoise_top_usage(struct osnoise_top_params= *params, char *usage) " d:runtime[us|ms|s]:period[us|ms|s] - use SCHED_DEADLINE with runtime = and period", " in nanoseconds", " --warm-up s: let the workload run for s seconds before collecting= data", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; =20 @@ -384,13 +386,14 @@ struct osnoise_top_params *osnoise_top_parse_args(int= argc, char **argv) {"trigger", required_argument, 0, '0'}, {"filter", required_argument, 0, '1'}, {"warm-up", required_argument, 0, '2'}, + {"trace-buffer-size", required_argument, 0, '3'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:", + c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:p:P:qr:s:S:t::T:0:1:2:3:", long_options, &option_index); =20 /* Detect the end of the options. */ @@ -517,6 +520,9 @@ struct osnoise_top_params *osnoise_top_parse_args(int a= rgc, char **argv) case '2': params->warmup =3D get_llong_from_str(optarg); break; + case '3': + params->buffer_size =3D get_llong_from_str(optarg); + break; default: osnoise_top_usage(params, "Invalid option"); } @@ -725,6 +731,12 @@ int osnoise_top_main(int argc, char **argv) if (retval) goto out_top; } + + if (params->buffer_size > 0) { + retval =3D trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_top; + } } =20 /* diff --git a/tools/tracing/rtla/src/timerlat_hist.c b/tools/tracing/rtla/sr= c/timerlat_hist.c index 6eb6e38d4a05..d4bab86ca1b9 100644 --- a/tools/tracing/rtla/src/timerlat_hist.c +++ b/tools/tracing/rtla/src/timerlat_hist.c @@ -54,6 +54,7 @@ struct timerlat_hist_params { int bucket_size; int entries; int warmup; + int buffer_size; }; =20 struct timerlat_hist_cpu { @@ -669,6 +670,7 @@ static void timerlat_hist_usage(char *usage) " -k/--kernel-threads: use timerlat kernel-space threads instead of rt= la user-space threads", " -U/--user-load: enable timerlat for user-defined user-space workload= ", " --warm-up s: let the workload run for s seconds before collecting= data", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; =20 @@ -745,13 +747,14 @@ static struct timerlat_hist_params {"no-aa", no_argument, 0, '9'}, {"dump-task", no_argument, 0, '\1'}, {"warm-up", required_argument, 0, '\2'}, + {"trace-buffer-size", required_argument, 0, '\3'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU01234= 56:7:8:9\1\2:", + c =3D getopt_long(argc, argv, "a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU01234= 56:7:8:9\1\2:\3", long_options, &option_index); =20 /* detect the end of the options. */ @@ -926,6 +929,9 @@ static struct timerlat_hist_params case '\2': params->warmup =3D get_llong_from_str(optarg); break; + case '\3': + params->buffer_size =3D get_llong_from_str(optarg); + break; default: timerlat_hist_usage("Invalid option"); } @@ -1179,6 +1185,12 @@ int timerlat_hist_main(int argc, char *argv[]) if (retval) goto out_hist; } + + if (params->buffer_size > 0) { + retval =3D trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_hist; + } } =20 if (!params->no_aa) { diff --git a/tools/tracing/rtla/src/timerlat_top.c b/tools/tracing/rtla/src= /timerlat_top.c index 0acfefe151f7..3a23e8d481c6 100644 --- a/tools/tracing/rtla/src/timerlat_top.c +++ b/tools/tracing/rtla/src/timerlat_top.c @@ -47,6 +47,7 @@ struct timerlat_top_params { int kernel_workload; int pretty_output; int warmup; + int buffer_size; cpu_set_t hk_cpu_set; struct sched_attr sched_param; struct trace_events *events; @@ -479,6 +480,7 @@ static void timerlat_top_usage(char *usage) " -k/--kernel-threads: use timerlat kernel-space threads instead of rt= la user-space threads", " -U/--user-load: enable timerlat for user-defined user-space workload= ", " --warm-up s: let the workload run for s seconds before collecting= data", + " --trace-buffer-size kB: set the per-cpu trace buffer size in kB", NULL, }; =20 @@ -547,13 +549,14 @@ static struct timerlat_top_params {"dump-tasks", no_argument, 0, '4'}, {"aa-only", required_argument, 0, '5'}, {"warm-up", required_argument, 0, '6'}, + {"trace-buffer-size", required_argument, 0, '7'}, {0, 0, 0, 0} }; =20 /* getopt_long stores the option index here. */ int option_index =3D 0; =20 - c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:34= 5:6:", + c =3D getopt_long(argc, argv, "a:c:C::d:De:hH:i:knp:P:qs:t::T:uU0:1:2:34= 5:6:7:", long_options, &option_index); =20 /* detect the end of the options. */ @@ -716,6 +719,9 @@ static struct timerlat_top_params case '6': params->warmup =3D get_llong_from_str(optarg); break; + case '7': + params->buffer_size =3D get_llong_from_str(optarg); + break; default: timerlat_top_usage("Invalid option"); } @@ -973,6 +979,12 @@ int timerlat_top_main(int argc, char *argv[]) if (retval) goto out_top; } + + if (params->buffer_size > 0) { + retval =3D trace_set_buffer_size(&record->trace, params->buffer_size); + if (retval) + goto out_top; + } } =20 if (!params->no_aa) { diff --git a/tools/tracing/rtla/src/trace.c b/tools/tracing/rtla/src/trace.c index e1ba6d9f4265..170a706248ab 100644 --- a/tools/tracing/rtla/src/trace.c +++ b/tools/tracing/rtla/src/trace.c @@ -540,3 +540,18 @@ int trace_is_off(struct trace_instance *tool, struct t= race_instance *trace) =20 return 0; } + +/* + * trace_set_buffer_size - set the per-cpu tracing buffer size. + */ +int trace_set_buffer_size(struct trace_instance *trace, int size) +{ + int retval; + + debug_msg("Setting trace buffer size to %d Kb\n", size); + retval =3D tracefs_instance_set_buffer_size(trace->inst, size, -1); + if (retval) + err_msg("Error setting trace buffer size\n"); + + return retval; +} diff --git a/tools/tracing/rtla/src/trace.h b/tools/tracing/rtla/src/trace.h index 2e9a89a25615..c7c92dc9a18a 100644 --- a/tools/tracing/rtla/src/trace.h +++ b/tools/tracing/rtla/src/trace.h @@ -48,3 +48,4 @@ int trace_events_enable(struct trace_instance *instance, int trace_event_add_filter(struct trace_events *event, char *filter); int trace_event_add_trigger(struct trace_events *event, char *trigger); int trace_is_off(struct trace_instance *tool, struct trace_instance *trace= ); +int trace_set_buffer_size(struct trace_instance *trace, int size); --=20 2.44.0