diff options
| author | Fan Yu <[email protected]> | 2025-07-31 14:53:26 +0000 |
|---|---|---|
| committer | Andrew Morton <[email protected]> | 2025-08-02 19:01:41 +0000 |
| commit | 085dece6cc88b5c6fc6f2eca0403bfd2c5fbc7cb (patch) | |
| tree | 7bc89ef8b4899d798a685d19b3b69dde0647ffd7 /scripts/rustdoc_test_gen.rs | |
| parent | kho: add test for kexec handover (diff) | |
| download | kernel-085dece6cc88b5c6fc6f2eca0403bfd2c5fbc7cb.tar.gz kernel-085dece6cc88b5c6fc6f2eca0403bfd2c5fbc7cb.zip | |
tools/getdelays: add backward compatibility for taskstats version
Add version checks to print_delayacct() to handle differences in struct
taskstats across kernel versions. Field availability depends on taskstats
version (t->version), corresponding to TASKSTATS_VERSION in kernel headers
(see include/uapi/linux/taskstats.h).
Version feature mapping:
- version >= 11 - supports COMPACT statistics
- version >= 13 - supports WPCOPY statistics
- version >= 14 - supports IRQ statistics
- version >= 16 - supports *_max and *_min delay statistics
This ensures the tool works correctly with both older and newer kernel
versions by conditionally printing fields based on the reported version.
eg.1
bash# grep -r "#define TASKSTATS_VERSION" /usr/include/linux/taskstats.h
"#define TASKSTATS_VERSION 10"
bash# ./getdelays -d -p 1
CPU count real total virtual total delay total delay average
7481 3786181709 3807098291 36393725 0.005ms
IO count delay total delay average
369 1116046035 3.025ms
SWAP count delay total delay average
0 0 0.000ms
RECLAIM count delay total delay average
0 0 0.000ms
THRASHING count delay total delay average
0 0 0.000ms
eg.2
bash# grep -r "#define TASKSTATS_VERSION" /usr/include/linux/taskstats.h
"#define TASKSTATS_VERSION 14"
bash# ./getdelays -d -p 1
CPU count real total virtual total delay total delay average
68862 163474790046 174584722267 19962496806 0.290ms
IO count delay total delay average
0 0 0.000ms
SWAP count delay total delay average
0 0 0.000ms
RECLAIM count delay total delay average
0 0 0.000ms
THRASHING count delay total delay average
0 0 0.000ms
COMPACT count delay total delay average
0 0 0.000ms
WPCOPY count delay total delay average
0 0 0.000ms
IRQ count delay total delay average
0 0 0.000ms
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Fan Yu <[email protected]>
Cc: Fan Yu <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Wang Yaxin <[email protected]>
Cc: xu xin <[email protected]>
Cc: Yang Yang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'scripts/rustdoc_test_gen.rs')
0 files changed, 0 insertions, 0 deletions
