Skip to content

Commit 1777e47

Browse files
committed
Merge tag 'trace-tools-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing tools updates from Steven Rostedt: "Trivial updates for 6.11: - Use pretty formatting only on interactive tty in rtla/osnoise - Better reporting when histogram is empty in rtla/osnoise - Use the correct library name for "libtracefs" in feature detection" * tag 'trace-tools-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tools: build: use correct lib name for libtracefs feature detection rtla/osnoise: Better report when histogram is empty rtla/osnoise: Use pretty formatting only on interactive tty
2 parents 70045bf + 28beb73 commit 1777e47

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

tools/build/feature/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ $(OUTPUT)test-libtraceevent.bin:
213213
$(BUILD) -ltraceevent
214214

215215
$(OUTPUT)test-libtracefs.bin:
216-
$(BUILD) $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null) -ltracefs
216+
$(BUILD) $(shell $(PKG_CONFIG) --cflags libtracefs 2>/dev/null) -ltracefs
217217

218218
$(OUTPUT)test-libcrypto.bin:
219219
$(BUILD) -lcrypto

tools/build/feature/test-libtracefs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
#include <tracefs/tracefs.h>
2+
#include <tracefs.h>
33

44
int main(void)
55
{

tools/tracing/rtla/src/osnoise_hist.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ osnoise_print_stats(struct osnoise_hist_params *params, struct osnoise_tool *too
374374
{
375375
struct osnoise_hist_data *data = tool->data;
376376
struct trace_instance *trace = &tool->trace;
377+
int has_samples = 0;
377378
int bucket, cpu;
378379
int total;
379380

@@ -402,11 +403,25 @@ osnoise_print_stats(struct osnoise_hist_params *params, struct osnoise_tool *too
402403
continue;
403404
}
404405

406+
/* There are samples above the threshold */
407+
has_samples = 1;
405408
trace_seq_printf(trace->seq, "\n");
406409
trace_seq_do_printf(trace->seq);
407410
trace_seq_reset(trace->seq);
408411
}
409412

413+
/*
414+
* If no samples were recorded, skip calculations, print zeroed statistics
415+
* and return.
416+
*/
417+
if (!has_samples) {
418+
trace_seq_reset(trace->seq);
419+
trace_seq_printf(trace->seq, "over: 0\ncount: 0\nmin: 0\navg: 0\nmax: 0\n");
420+
trace_seq_do_printf(trace->seq);
421+
trace_seq_reset(trace->seq);
422+
return;
423+
}
424+
410425
if (!params->no_index)
411426
trace_seq_printf(trace->seq, "over: ");
412427

tools/tracing/rtla/src/osnoise_top.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct osnoise_top_params {
4242
int hk_cpus;
4343
int warmup;
4444
int buffer_size;
45+
int pretty_output;
4546
cpu_set_t hk_cpu_set;
4647
struct sched_attr sched_param;
4748
struct trace_events *events;
@@ -163,7 +164,9 @@ static void osnoise_top_header(struct osnoise_tool *top)
163164

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

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

169172
if (params->mode == MODE_OSNOISE) {
@@ -174,12 +177,16 @@ static void osnoise_top_header(struct osnoise_tool *top)
174177
}
175178

176179
trace_seq_printf(s, " ");
177-
trace_seq_printf(s, "\033[0;0;0m");
180+
181+
if (params->pretty_output)
182+
trace_seq_printf(s, "\033[0;0;0m");
178183
trace_seq_printf(s, "\n");
179184

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

182-
trace_seq_printf(s, "\033[2;30;47m");
187+
if (params->pretty_output)
188+
trace_seq_printf(s, "\033[2;30;47m");
189+
183190
trace_seq_printf(s, "CPU Period Runtime ");
184191
trace_seq_printf(s, " Noise ");
185192
trace_seq_printf(s, " %% CPU Aval ");
@@ -192,7 +199,8 @@ static void osnoise_top_header(struct osnoise_tool *top)
192199
trace_seq_printf(s, " IRQ Softirq Thread");
193200

194201
eol:
195-
trace_seq_printf(s, "\033[0;0;0m");
202+
if (params->pretty_output)
203+
trace_seq_printf(s, "\033[0;0;0m");
196204
trace_seq_printf(s, "\n");
197205
}
198206

@@ -619,6 +627,9 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
619627
auto_house_keeping(&params->monitored_cpus);
620628
}
621629

630+
if (isatty(1) && !params->quiet)
631+
params->pretty_output = 1;
632+
622633
return 0;
623634

624635
out_err:

0 commit comments

Comments
 (0)