* [PATCH 1/3] rtla/osnoise: Use pretty formatting only on interactive tty
@ 2024-06-10 13:25 Luis Claudio R. Goncalves
2024-06-10 13:48 ` Luis Claudio R. Goncalves
0 siblings, 1 reply; 2+ messages in thread
From: Luis Claudio R. Goncalves @ 2024-06-10 13:25 UTC (permalink / raw)
To: Daniel Bristot de Oliveira, Steven Rostedt, John Kacur,
linux-trace-kernel, linux-kernel
osnoise top performs background/font color formatting that could make
the text output confusing if not on a terminal. Use the changes from
commit f5c0cdad6684a ("rtla/timerlat: Use pretty formatting only on
interactive tty") as an inspiration to fix this problem.
Apply the formatting only if running on a tty, and not in quiet mode.
Suggested-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Reviewed-by: John Kacur <jkacur@redhat.com>
Reviewed-by: Clark Williams <williams@redhat.com>
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
---
tools/tracing/rtla/src/osnoise_top.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
index 07ba55d4ec06f..d539fade99d48 100644
--- a/tools/tracing/rtla/src/osnoise_top.c
+++ b/tools/tracing/rtla/src/osnoise_top.c
@@ -42,6 +42,7 @@ struct osnoise_top_params {
int hk_cpus;
int warmup;
int buffer_size;
+ int pretty_output;
cpu_set_t hk_cpu_set;
struct sched_attr sched_param;
struct trace_events *events;
@@ -163,7 +164,9 @@ static void osnoise_top_header(struct osnoise_tool *top)
get_duration(top->start_time, duration, sizeof(duration));
- trace_seq_printf(s, "\033[2;37;40m");
+ if (params->pretty_output)
+ trace_seq_printf(s, "\033[2;37;40m");
+
trace_seq_printf(s, " ");
if (params->mode == MODE_OSNOISE) {
@@ -174,12 +177,16 @@ static void osnoise_top_header(struct osnoise_tool *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");
trace_seq_printf(s, "duration: %9s | time is in us\n", duration);
- 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 Period Runtime ");
trace_seq_printf(s, " Noise ");
trace_seq_printf(s, " %% CPU Aval ");
@@ -192,7 +199,8 @@ static void osnoise_top_header(struct osnoise_tool *top)
trace_seq_printf(s, " IRQ Softirq Thread");
eol:
- 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");
}
@@ -619,6 +627,9 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
auto_house_keeping(¶ms->monitored_cpus);
}
+ if (isatty(1) && !params->quiet)
+ params->pretty_output = 1;
+
return 0;
out_err:
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/3] rtla/osnoise: Use pretty formatting only on interactive tty
2024-06-10 13:25 [PATCH 1/3] rtla/osnoise: Use pretty formatting only on interactive tty Luis Claudio R. Goncalves
@ 2024-06-10 13:48 ` Luis Claudio R. Goncalves
0 siblings, 0 replies; 2+ messages in thread
From: Luis Claudio R. Goncalves @ 2024-06-10 13:48 UTC (permalink / raw)
To: Daniel Bristot de Oliveira, Steven Rostedt, John Kacur,
linux-trace-kernel, linux-kernel
This is a single patch, selected out of a test series. I messed up the
subject giving the impression that more patches were to come.
Sorry for any inconvenience,
Luis
On Mon, Jun 10, 2024 at 10:25:28AM -0300, Luis Claudio R. Goncalves wrote:
> osnoise top performs background/font color formatting that could make
> the text output confusing if not on a terminal. Use the changes from
> commit f5c0cdad6684a ("rtla/timerlat: Use pretty formatting only on
> interactive tty") as an inspiration to fix this problem.
>
> Apply the formatting only if running on a tty, and not in quiet mode.
>
> Suggested-by: Daniel Bristot de Oliveira <bristot@kernel.org>
> Reviewed-by: John Kacur <jkacur@redhat.com>
> Reviewed-by: Clark Williams <williams@redhat.com>
> Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
> ---
> tools/tracing/rtla/src/osnoise_top.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/tools/tracing/rtla/src/osnoise_top.c b/tools/tracing/rtla/src/osnoise_top.c
> index 07ba55d4ec06f..d539fade99d48 100644
> --- a/tools/tracing/rtla/src/osnoise_top.c
> +++ b/tools/tracing/rtla/src/osnoise_top.c
> @@ -42,6 +42,7 @@ struct osnoise_top_params {
> int hk_cpus;
> int warmup;
> int buffer_size;
> + int pretty_output;
> cpu_set_t hk_cpu_set;
> struct sched_attr sched_param;
> struct trace_events *events;
> @@ -163,7 +164,9 @@ static void osnoise_top_header(struct osnoise_tool *top)
>
> get_duration(top->start_time, duration, sizeof(duration));
>
> - trace_seq_printf(s, "\033[2;37;40m");
> + if (params->pretty_output)
> + trace_seq_printf(s, "\033[2;37;40m");
> +
> trace_seq_printf(s, " ");
>
> if (params->mode == MODE_OSNOISE) {
> @@ -174,12 +177,16 @@ static void osnoise_top_header(struct osnoise_tool *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");
>
> trace_seq_printf(s, "duration: %9s | time is in us\n", duration);
>
> - 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 Period Runtime ");
> trace_seq_printf(s, " Noise ");
> trace_seq_printf(s, " %% CPU Aval ");
> @@ -192,7 +199,8 @@ static void osnoise_top_header(struct osnoise_tool *top)
> trace_seq_printf(s, " IRQ Softirq Thread");
>
> eol:
> - 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");
> }
>
> @@ -619,6 +627,9 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
> auto_house_keeping(¶ms->monitored_cpus);
> }
>
> + if (isatty(1) && !params->quiet)
> + params->pretty_output = 1;
> +
> return 0;
>
> out_err:
> --
> 2.45.2
>
>
---end quoted text---
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-10 13:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10 13:25 [PATCH 1/3] rtla/osnoise: Use pretty formatting only on interactive tty Luis Claudio R. Goncalves
2024-06-10 13:48 ` Luis Claudio R. Goncalves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).