Skip to content

Commit 8860575

Browse files
committed
rtla/osnoise: Use pretty formatting only on interactive tty
JIRA: https://issues.redhat.com/browse/RHEL-50869 commit 59237b0 Author: Luis Claudio R. Goncalves <lgoncalv@redhat.com> Date: Mon Jun 10 10:25:28 2024 -0300 rtla/osnoise: Use pretty formatting only on interactive tty osnoise top performs background/font color formatting that could make the text output confusing if not on a terminal. Use the changes from commit f5c0cda ("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> Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
1 parent c0e795b commit 8860575

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct osnoise_top_params {
4141
int cgroup;
4242
int hk_cpus;
4343
int warmup;
44+
int pretty_output;
4445
cpu_set_t hk_cpu_set;
4546
struct sched_attr sched_param;
4647
struct trace_events *events;
@@ -162,7 +163,9 @@ static void osnoise_top_header(struct osnoise_tool *top)
162163

163164
get_duration(top->start_time, duration, sizeof(duration));
164165

165-
trace_seq_printf(s, "\033[2;37;40m");
166+
if (params->pretty_output)
167+
trace_seq_printf(s, "\033[2;37;40m");
168+
166169
trace_seq_printf(s, " ");
167170

168171
if (params->mode == MODE_OSNOISE) {
@@ -173,12 +176,16 @@ static void osnoise_top_header(struct osnoise_tool *top)
173176
}
174177

175178
trace_seq_printf(s, " ");
176-
trace_seq_printf(s, "\033[0;0;0m");
179+
180+
if (params->pretty_output)
181+
trace_seq_printf(s, "\033[0;0;0m");
177182
trace_seq_printf(s, "\n");
178183

179184
trace_seq_printf(s, "duration: %9s | time is in us\n", duration);
180185

181-
trace_seq_printf(s, "\033[2;30;47m");
186+
if (params->pretty_output)
187+
trace_seq_printf(s, "\033[2;30;47m");
188+
182189
trace_seq_printf(s, "CPU Period Runtime ");
183190
trace_seq_printf(s, " Noise ");
184191
trace_seq_printf(s, " %% CPU Aval ");
@@ -191,7 +198,8 @@ static void osnoise_top_header(struct osnoise_tool *top)
191198
trace_seq_printf(s, " IRQ Softirq Thread");
192199

193200
eol:
194-
trace_seq_printf(s, "\033[0;0;0m");
201+
if (params->pretty_output)
202+
trace_seq_printf(s, "\033[0;0;0m");
195203
trace_seq_printf(s, "\n");
196204
}
197205

@@ -613,6 +621,9 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
613621
auto_house_keeping(&params->monitored_cpus);
614622
}
615623

624+
if (isatty(1) && !params->quiet)
625+
params->pretty_output = 1;
626+
616627
return 0;
617628

618629
out_err:

0 commit comments

Comments
 (0)