[PATCH 0/3] tools/accounting: refactor delay fields and share format_timespec()

wang.yaxin@zte.com.cn posted 3 patches 2 weeks ago
There is a newer version of this series
tools/accounting/Makefile             |  12 +-
tools/accounting/delaytop.c           | 261 +++++++++-----------------
tools/accounting/format_timespec.c    |  37 ++++
tools/accounting/format_timespec.h    |   9 +
tools/accounting/getdelays.c          |  32 +---
tools/include/uapi/linux/time_types.h |  18 ++
6 files changed, 169 insertions(+), 200 deletions(-)
create mode 100644 tools/accounting/format_timespec.c
create mode 100644 tools/accounting/format_timespec.h
create mode 100644 tools/include/uapi/linux/time_types.h
[PATCH 0/3] tools/accounting: refactor delay fields and share format_timespec()
Posted by wang.yaxin@zte.com.cn 2 weeks ago
From: Wang Yaxin <wang.yaxin@zte.com.cn>

- Convert per-field delay members in struct task_info to an array indexed
  by enum delay_type, eliminating offsetof() pointer arithmetic.

- Factor out a common format_timespec() implementation shared by getdelays
  and delaytop, using strftime for cleaner timestamp formatting.

- Replace the complex sizeof/ULL/shift Y2038 guard with a direct narrowing
  truncation check ((long long)time_sec != ts->tv_sec).

Wang Yaxin (3):
  delaytop: refactor repetitive delay fields into array with enum
  tools/accounting: factor out shared format_timespec() implementation
  tools/accounting: simplify 32-bit time_t overflow check in
    format_timespec()

 tools/accounting/Makefile             |  12 +-
 tools/accounting/delaytop.c           | 261 +++++++++-----------------
 tools/accounting/format_timespec.c    |  37 ++++
 tools/accounting/format_timespec.h    |   9 +
 tools/accounting/getdelays.c          |  32 +---
 tools/include/uapi/linux/time_types.h |  18 ++
 6 files changed, 169 insertions(+), 200 deletions(-)
 create mode 100644 tools/accounting/format_timespec.c
 create mode 100644 tools/accounting/format_timespec.h
 create mode 100644 tools/include/uapi/linux/time_types.h

-- 
2.27.0
Re: [PATCH 0/3] tools/accounting: refactor delay fields and share format_timespec()
Posted by Andrew Morton 1 week, 4 days ago
On Sat, 11 Jul 2026 17:31:12 +0800 (CST) <wang.yaxin@zte.com.cn> wrote:

> - Convert per-field delay members in struct task_info to an array indexed
>   by enum delay_type, eliminating offsetof() pointer arithmetic.
> 
> - Factor out a common format_timespec() implementation shared by getdelays
>   and delaytop, using strftime for cleaner timestamp formatting.
> 
> - Replace the complex sizeof/ULL/shift Y2038 guard with a direct narrowing
>   truncation check ((long long)time_sec != ts->tv_sec).

Sounds great.

AI review might have found a couple of things.  Please check it out?
	https://sashiko.dev/#/patchset/20260711173112482SCQEM08VED2PT1pxUYOXk@zte.com.cn