Skip to content

Commit 01b05fc

Browse files
John KacurDaniel Bristot de Oliveira
authored andcommitted
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/[email protected] Cc: [email protected] Fixes: 1eeb632 ("rtla/timerlat: Add timerlat hist mode") Suggested-by: Daniel Bristot de Oliveria <[email protected]> Signed-off-by: John Kacur <[email protected]> Signed-off-by: Daniel Bristot de Oliveira <[email protected]>
1 parent e9a4062 commit 01b05fc

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
@@ -327,17 +327,29 @@ timerlat_print_summary(struct timerlat_hist_params *params,
327327
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
328328
continue;
329329

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

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

338-
if (params->user_hist)
339-
trace_seq_printf(trace->seq, "%9llu ",
340-
data->hist[cpu].min_user);
346+
if (params->user_hist) {
347+
if (data->hist[cpu].user_count)
348+
trace_seq_printf(trace->seq, "%9llu ",
349+
data->hist[cpu].min_user);
350+
else
351+
trace_seq_printf(trace->seq, " - ");
352+
}
341353
}
342354
trace_seq_printf(trace->seq, "\n");
343355

@@ -387,17 +399,29 @@ timerlat_print_summary(struct timerlat_hist_params *params,
387399
if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count)
388400
continue;
389401

390-
if (!params->no_irq)
391-
trace_seq_printf(trace->seq, "%9llu ",
392-
data->hist[cpu].max_irq);
402+
if (!params->no_irq) {
403+
if (data->hist[cpu].irq_count)
404+
trace_seq_printf(trace->seq, "%9llu ",
405+
data->hist[cpu].max_irq);
406+
else
407+
trace_seq_printf(trace->seq, " - ");
408+
}
393409

394-
if (!params->no_thread)
395-
trace_seq_printf(trace->seq, "%9llu ",
396-
data->hist[cpu].max_thread);
410+
if (!params->no_thread) {
411+
if (data->hist[cpu].thread_count)
412+
trace_seq_printf(trace->seq, "%9llu ",
413+
data->hist[cpu].max_thread);
414+
else
415+
trace_seq_printf(trace->seq, " - ");
416+
}
397417

398-
if (params->user_hist)
399-
trace_seq_printf(trace->seq, "%9llu ",
400-
data->hist[cpu].max_user);
418+
if (params->user_hist) {
419+
if (data->hist[cpu].user_count)
420+
trace_seq_printf(trace->seq, "%9llu ",
421+
data->hist[cpu].max_user);
422+
else
423+
trace_seq_printf(trace->seq, " - ");
424+
}
401425
}
402426
trace_seq_printf(trace->seq, "\n");
403427
trace_seq_do_printf(trace->seq);

0 commit comments

Comments
 (0)