Skip to content

Commit e1f2372

Browse files
committed
rtla/osnoise: Better report when histogram is empty
JIRA: https://issues.redhat.com/browse/RHEL-50869 commit 587f05a Author: Luis Claudio R. Goncalves <lgoncalv@redhat.com> Date: Wed Jun 12 07:36:22 2024 -0300 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/Zml6JmH5cbS7-HfZ@uudg.org Cc: Daniel Bristot de Oliveira <bristot@kernel.org> Cc: John Kacur <jkacur@redhat.com> Cc: Clark Williams <williams@redhat.com> Reviewed-by: John Kacur <jkacur@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 8860575 commit e1f2372

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
@@ -373,6 +373,7 @@ osnoise_print_stats(struct osnoise_hist_params *params, struct osnoise_tool *too
373373
{
374374
struct osnoise_hist_data *data = tool->data;
375375
struct trace_instance *trace = &tool->trace;
376+
int has_samples = 0;
376377
int bucket, cpu;
377378
int total;
378379

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

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

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

0 commit comments

Comments
 (0)