|
|
Log in / Subscribe / Register

delaytop: add delay max, timestamp and sorting for top latency analysis

From:  wang.yaxin-AT-zte.com.cn
To:  <akpm-AT-linux-foundation.org>, <fan.yu9-AT-zte.com.cn>, <yang.yang29-AT-zte.com.cn>
Subject:  [PATCH 0/3 v2] delaytop: add delay max, timestamp and sorting for top latency analysis
Date:  Sat, 30 May 2026 11:16:02 +0800
Message-ID:  <20260530111602822agJB6QYfIc2NKfQBK1KYf@zte.com.cn>
Cc:  <corbet-AT-lwn.net>, <linux-kernel-AT-vger.kernel.org>, <linux-doc-AT-vger.kernel.org>, <xu.xin16-AT-zte.com.cn>, <wang.yaxin-AT-zte.com.cn>
Archive-link:  Article

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.19726c1c89a94b...
[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



Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds