From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Daniel Wagner <dwagner@suse.de>,
"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
Clark Williams <williams@redhat.com>,
Daniel Bristot de Oliveira <bristot@kernel.org>,
John Kacur <jkacur@redhat.com>
Subject: [for-next][PATCH 1/3] rtla/osnoise: Use pretty formatting only on interactive tty
Date: Thu, 27 Jun 2024 16:50:23 -0400 [thread overview]
Message-ID: <20240627210256.595062681@goodmis.org> (raw)
In-Reply-To: 20240627205022.857212058@goodmis.org
From: "Luis Claudio R. Goncalves" <lgoncalv@redhat.com>
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.
Link: https://lkml.kernel.org/r/Zmb-yP_3EDHliI8Z@uudg.org
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>
Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
---
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 07ba55d4ec06..f594a44df840 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.43.0
next prev parent reply other threads:[~2024-06-27 21:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-27 20:50 [for-next][PATCH 0/3] tracing/tools: Updates for 6.11 Steven Rostedt
2024-06-27 20:50 ` Steven Rostedt [this message]
2024-06-27 20:50 ` [for-next][PATCH 2/3] rtla/osnoise: Better report when histogram is empty Steven Rostedt
2024-06-27 20:50 ` [for-next][PATCH 3/3] tools: build: use correct lib name for libtracefs feature detection Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240627210256.595062681@goodmis.org \
--to=rostedt@goodmis.org \
--cc=bristot@kernel.org \
--cc=dwagner@suse.de \
--cc=jkacur@redhat.com \
--cc=lgoncalv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=williams@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox