Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 1eeb6328e8b3 ("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>

authored by

John Kacur and committed by
Daniel Bristot de Oliveira
01b05fc0 e9a4062e

+42 -18
+42 -18
tools/tracing/rtla/src/timerlat_hist.c
··· 327 327 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 328 328 continue; 329 329 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 + } 333 337 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 + } 337 345 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 + } 341 353 } 342 354 trace_seq_printf(trace->seq, "\n"); 343 355 ··· 399 387 if (!data->hist[cpu].irq_count && !data->hist[cpu].thread_count) 400 388 continue; 401 389 402 - if (!params->no_irq) 403 - trace_seq_printf(trace->seq, "%9llu ", 404 - data->hist[cpu].max_irq); 390 + if (!params->no_irq) { 391 + if (data->hist[cpu].irq_count) 392 + trace_seq_printf(trace->seq, "%9llu ", 393 + data->hist[cpu].max_irq); 394 + else 395 + trace_seq_printf(trace->seq, " - "); 396 + } 405 397 406 - if (!params->no_thread) 407 - trace_seq_printf(trace->seq, "%9llu ", 408 - data->hist[cpu].max_thread); 398 + if (!params->no_thread) { 399 + if (data->hist[cpu].thread_count) 400 + trace_seq_printf(trace->seq, "%9llu ", 401 + data->hist[cpu].max_thread); 402 + else 403 + trace_seq_printf(trace->seq, " - "); 404 + } 409 405 410 - if (params->user_hist) 411 - trace_seq_printf(trace->seq, "%9llu ", 412 - data->hist[cpu].max_user); 406 + if (params->user_hist) { 407 + if (data->hist[cpu].user_count) 408 + trace_seq_printf(trace->seq, "%9llu ", 409 + data->hist[cpu].max_user); 410 + else 411 + trace_seq_printf(trace->seq, " - "); 412 + } 413 413 } 414 414 trace_seq_printf(trace->seq, "\n"); 415 415 trace_seq_do_printf(trace->seq);