[PATCH v3 0/3] perf sched latency: Refine outputs, unit scaling, and histogram support
From: Aaron Tomlin
Date: Sat Jul 25 2026 - 23:25:52 EST
This patch series improves 'perf sched latency' by fixing misleading empty
table output, introducing dynamic unit auto-scaling for latency and runtime
statistics, and adding latency histogram visualisation alongside time-span
filtering.
Patch 1 fixes a bug where 'perf sched latency' would fall through and
return success (0) when perf_session__has_traces() failed due to missing
tracepoint events in perf.data. This resulted in empty header tables and
zeroed summary statistics being printed. The fix ensures an early return of
a suitable error code.
Patch 2 introduces dynamic auto-scaling for display columns (Runtime, Avg
delay, Max delay). Previously, all values were unconditionally formatted in
milliseconds (ms), making microsecond or second-scale latencies difficult
to read. Columns are now scaled dynamically to the most appropriate unit
(ns, us, ms, s) and headers are updated accordingly.
Patch 3 adds three new command-line options to 'perf sched latency':
--histogram (-H):
Displays an ASCII bar chart of CPU wait latencies between
snapshots
--hist-mode:
Configures the bucketing scheme to either logarithmic (log) or
100 us equal-width linear (linear) mode
--time:
Filters event processing to a specified [start,stop] time span
Changes since v2:
- Ensured vertical pipe separators align across all latency table columns
- Excluded "swapper" (idle thread) latency samples from global_hist
- Preserved task state machine transitions across --time boundaries
- Suppressed empty table headers, total lines, and histogram graphs when
no matching trace samples exist (e.g., when --time, --CPU, or --pids
exclude all samples), outputting "No matching trace samples found."
instead
- Linked to v2: https://lore.kernel.org/lkml/20260725173341.679782-1-atomlin@xxxxxxxxxxx/
Changes since v1:
- Fixed integer overflow in latency_bucket() (Ian Rogers)
- Linked to v1: https://lore.kernel.org/lkml/20260724142901.634761-1-atomlin@xxxxxxxxxxx/
Aaron Tomlin (3):
perf sched: Suppress latency table output when trace samples are
missing
perf sched latency: Auto-scale latency and runtime display units
perf sched latency: Add histogram and time interval options
tools/perf/Documentation/perf-sched.txt | 6 +
tools/perf/builtin-sched.c | 246 ++++++++++++++++++++++--
2 files changed, 231 insertions(+), 21 deletions(-)
--
2.54.0