Skip to content

Commit 587f05a

Browse files
lclaudioDaniel Bristot de Oliveira
authored andcommitted
rtla/osnoise: Better report when histogram is empty
When osnoise hist does not observe any samples above the threshold, no entries are recorded and the final report shows empty entries for the usual statistics (count, min, max, avg): [~]# osnoise hist -d 5s -T 500 # RTLA osnoise histogram # Time unit is microseconds (us) # Duration: 0 00:00:05 Index over: count: min: avg: max: That could lead users to confusing interpretations of the results. A simple solution is to report 0 for count and the statistics, making it clear that no noise (above the defined threshold) was observed: [~]# osnoise hist -d 5s -T 500 # RTLA osnoise histogram # Time unit is microseconds (us) # Duration: 0 00:00:05 Index over: 0 count: 0 min: 0 avg: 0 max: 0 Link: https://lkml.kernel.org/r/[email protected] Cc: Daniel Bristot de Oliveira <[email protected]> Cc: John Kacur <[email protected]> Cc: Clark Williams <[email protected]> Reviewed-by: John Kacur <[email protected]> Signed-off-by: Luis Claudio R. Goncalves <[email protected]> Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
1 parent 59237b0 commit 587f05a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

0 commit comments

Comments
 (0)