[PATCH 0/3 v2] delaytop: add delay max, timestamp and sorting for top latency analysis

wang.yaxin@zte.com.cn posted 3 patches 1 week, 2 days ago
Documentation/accounting/delay-accounting.rst |  43 +++
tools/accounting/delaytop.c                   | 263 ++++++++++++++++--
2 files changed, 276 insertions(+), 30 deletions(-)
[PATCH 0/3 v2] delaytop: add delay max, timestamp and sorting for top latency analysis
Posted by wang.yaxin@zte.com.cn 1 week, 2 days ago
From: Wang Yaxin <wang.yaxin@zte.com.cn>

Previously delaytop only showed average delays. This patch adds:

1. delay_max fields to track the maximum delay value for each delay type
   (cpu, blkio, irq, swapin, freepages, thrashing, compact, wpcopy)
   per task.

2. The -t/--type option displays only the specified delay type with avg/max
   values side by side, allowing focused analysis:
     delaytop -t cpu    # Show only CPU delay with avg/max
     delaytop -t wpcopy # Show Copy-on-Write delay with avg/max

3. Wall-clock timestamp when each maximum delay occurred, displayed in the
   MAX_TIMESTAMP column when using -t/--type option. This enables:
   - Identifying the time when a process experienced an abnormal delay max
   - Correlating delay max across multiple processes at the same timestamp
   - Cross-referencing with logs, traces, or other metrics at that time

4. When using -t/--type option, tasks are sorted by maximum delay value in
   descending order (largest delay first), enabling quick identification of
   top N processes with highest delay spikes.

Signed-off-by: Wang Yaxin <wang.yaxin@zte.com.cn>

v1->v2:
https://lore.kernel.org/all/20260527124210.19726c1c89a94b89310e5a47@linux-foundation.org/
[patch 1/3]
1. Fix potential NULL pointer dereference in get_field_by_name().
2. Fix data truncation by changing count pointer type from unsigned long to
	unsigned long long.
3. Fix column misalignment by changing COMMAND format from %-15s to %-17s.

[patch 2/3]
1. Add missing freepages_delay_max_ts initialization to avoid stale
	timestamps.
2. Fix Year 2038 regression by removing explicit time_t cast.

[patch 3/3]
1. Fix Y2038 truncation on 32-bit platforms by checking timestamp
	overflow before cast.
2. Mark field_delay_max_and_ts and get_field_delay_values as static
	to avoid missing-prototypes warnings.
3. Fix unexpected unindent in the Documentation.

Wang Yaxin (3):
  delaytop: add delay max for delaytop
  delaytop: add timestamp of delay max
  delaytop: sort by max delay to highlight top latency processes

 Documentation/accounting/delay-accounting.rst |  43 +++
 tools/accounting/delaytop.c                   | 263 ++++++++++++++++--
 2 files changed, 276 insertions(+), 30 deletions(-)

-- 
2.25.1