Skip to content

Commit 15f5528

Browse files
committed
rtla/timerlat: Fix histogram report when a cpu count is 0
JIRA: https://issues.redhat.com/browse/RHEL-50869 commit 01b05fc Author: John Kacur <jkacur@redhat.com> Date: Fri May 10 15:03:18 2024 -0400 rtla/timerlat: Fix histogram report when a cpu count is 0 On short runs it is possible to get no samples on a cpu, like this: # rtla timerlat hist -u -T50 Index IRQ-001 Thr-001 Usr-001 IRQ-002 Thr-002 Usr-002 2 1 0 0 0 0 0 33 0 1 0 0 0 0 36 0 0 1 0 0 0 49 0 0 0 1 0 0 52 0 0 0 0 1 0 over: 0 0 0 0 0 0 count: 1 1 1 1 1 0 min: 2 33 36 49 52 18446744073709551615 avg: 2 33 36 49 52 - max: 2 33 36 49 52 0 rtla timerlat hit stop tracing IRQ handler delay: (exit from idle) 48.21 us (91.09 %) IRQ latency: 49.11 us Timerlat IRQ duration: 2.17 us (4.09 %) Blocking thread: 1.01 us (1.90 %) swapper/2:0 1.01 us ------------------------------------------------------------------------ Thread latency: 52.93 us (100%) Max timerlat IRQ latency from idle: 49.11 us in cpu 2 Note, the value 18446744073709551615 is the same as ~0. Fix this by reporting no results for the min, avg and max if the count is 0. Link: https://lkml.kernel.org/r/20240510190318.44295-1-jkacur@redhat.com Cc: stable@vger.kernel.org Fixes: 1eeb632 ("rtla/timerlat: Add timerlat hist mode") Suggested-by: Daniel Bristot de Oliveria <bristot@kernel.org> Signed-off-by: John Kacur <jkacur@redhat.com> Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org> Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
1 parent cbf4906 commit 15f5528

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

tools/tracing/rtla/src/timerlat_hist.c

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -325,17 +325,29 @@ timerlat_print_summary(struct timerlat_hist_params *params,
325325
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
326326
continue;
327327

328-
if (!params->no_irq)
329-
trace_seq_printf(trace->seq, "%9llu ",
330-
data->hist[cpu].min_irq);
328+
if (!params->no_irq) {
329+
if (data->hist[cpu].irq_count)
330+
trace_seq_printf(trace->seq, "%9llu ",
331+
data->hist[cpu].min_irq);
332+
else
333+
trace_seq_printf(trace->seq, " - ");
334+
}
331335

332-
if (!params->no_thread)
333-
trace_seq_printf(trace->seq, "%9llu ",
334-
data->hist[cpu].min_thread);
336+
if (!params->no_thread) {
337+
if (data->hist[cpu].thread_count)
338+
trace_seq_printf(trace->seq, "%9llu ",
339+
data->hist[cpu].min_thread);
340+
else
341+
trace_seq_printf(trace->seq, " - ");
342+
}
335343

336-
if (params->user_hist)
337-
trace_seq_printf(trace->seq, "%9llu ",
338-
data->hist[cpu].min_user);
344+
if (params->user_hist) {
345+
if (data->hist[cpu].user_count)
346+
trace_seq_printf(trace->seq, "%9llu ",
347+
data->hist[cpu].min_user);
348+
else
349+
trace_seq_printf(trace->seq, " - ");
350+
}
339351
}
340352
trace_seq_printf(trace->seq, "\n");
341353

@@ -385,17 +397,29 @@ timerlat_print_summary(struct timerlat_hist_params *params,
385397
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
386398
continue;
387399

388-
if (!params->no_irq)
389-
trace_seq_printf(trace->seq, "%9llu ",
390-
data->hist[cpu].max_irq);
400+
if (!params->no_irq) {
401+
if (data->hist[cpu].irq_count)
402+
trace_seq_printf(trace->seq, "%9llu ",
403+
data->hist[cpu].max_irq);
404+
else
405+
trace_seq_printf(trace->seq, " - ");
406+
}
391407

392-
if (!params->no_thread)
393-
trace_seq_printf(trace->seq, "%9llu ",
394-
data->hist[cpu].max_thread);
408+
if (!params->no_thread) {
409+
if (data->hist[cpu].thread_count)
410+
trace_seq_printf(trace->seq, "%9llu ",
411+
data->hist[cpu].max_thread);
412+
else
413+
trace_seq_printf(trace->seq, " - ");
414+
}
395415

396-
if (params->user_hist)
397-
trace_seq_printf(trace->seq, "%9llu ",
398-
data->hist[cpu].max_user);
416+
if (params->user_hist) {
417+
if (data->hist[cpu].user_count)
418+
trace_seq_printf(trace->seq, "%9llu ",
419+
data->hist[cpu].max_user);
420+
else
421+
trace_seq_printf(trace->seq, " - ");
422+
}
399423
}
400424
trace_seq_printf(trace->seq, "\n");
401425
trace_seq_do_printf(trace->seq);

0 commit comments

Comments
 (0)