^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) The struct taskstats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ====================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) This document contains an explanation of the struct taskstats fields.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) There are three different groups of fields in the struct taskstats:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) 1) Common and basic accounting fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) If CONFIG_TASKSTATS is set, the taskstats interface is enabled and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) the common fields and basic accounting fields are collected for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) delivery at do_exit() of a task.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 2) Delay accounting fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) These fields are placed between::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /* Delay accounting fields start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) and::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /* Delay accounting fields end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Their values are collected if CONFIG_TASK_DELAY_ACCT is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 3) Extended accounting fields
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) These fields are placed between::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /* Extended accounting fields start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) and::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /* Extended accounting fields end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) Their values are collected if CONFIG_TASK_XACCT is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 4) Per-task and per-thread context switch count statistics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 5) Time accounting for SMT machines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 6) Extended delay accounting fields for memory reclaim
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) Future extension should add fields to the end of the taskstats struct, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) should not change the relative position of each field within the struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct taskstats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 1) Common and basic accounting fields::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* The version number of this struct. This field is always set to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * TAKSTATS_VERSION, which is defined in <linux/taskstats.h>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * Each time the struct is changed, the value should be incremented.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) __u16 version;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /* The exit code of a task. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) __u32 ac_exitcode; /* Exit status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /* The accounting flags of a task as defined in <linux/acct.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) __u8 ac_flag; /* Record flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* The value of task_nice() of a task. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) __u8 ac_nice; /* task_nice */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) /* The name of the command that started this task. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) char ac_comm[TS_COMM_LEN]; /* Command name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /* The scheduling discipline as set in task->policy field. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) __u8 ac_sched; /* Scheduling discipline */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) __u8 ac_pad[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) __u32 ac_uid; /* User ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) __u32 ac_gid; /* Group ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) __u32 ac_pid; /* Process ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) __u32 ac_ppid; /* Parent process ID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /* The time when a task begins, in [secs] since 1970. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) __u32 ac_btime; /* Begin time [sec since 1970] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /* The elapsed time of a task, in [usec]. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) __u64 ac_etime; /* Elapsed time [usec] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* The user CPU time of a task, in [usec]. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) __u64 ac_utime; /* User CPU time [usec] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) /* The system CPU time of a task, in [usec]. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) __u64 ac_stime; /* System CPU time [usec] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* The minor page fault count of a task, as set in task->min_flt. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) __u64 ac_minflt; /* Minor Page Fault Count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) /* The major page fault count of a task, as set in task->maj_flt. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) __u64 ac_majflt; /* Major Page Fault Count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) 2) Delay accounting fields::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /* Delay accounting fields start
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * All values, until the comment "Delay accounting fields end" are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * available only if delay accounting is enabled, even though the last
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * few fields are not delays
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * xxx_count is the number of delay values recorded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * xxx_delay_total is the corresponding cumulative delay in nanoseconds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * xxx_delay_total wraps around to zero on overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * xxx_count incremented regardless of overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /* Delay waiting for cpu, while runnable
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * count, delay_total NOT updated atomically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) __u64 cpu_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) __u64 cpu_delay_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /* Following four fields atomically updated using task->delays->lock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /* Delay waiting for synchronous block I/O to complete
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) * does not account for delays in I/O submission
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) __u64 blkio_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) __u64 blkio_delay_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) /* Delay waiting for page fault I/O (swap in only) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) __u64 swapin_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) __u64 swapin_delay_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /* cpu "wall-clock" running time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * On some architectures, value will adjust for cpu time stolen
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * from the kernel in involuntary waits due to virtualization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * Value is cumulative, in nanoseconds, without a corresponding count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * and wraps around to zero silently on overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) __u64 cpu_run_real_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) /* cpu "virtual" running time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * Uses time intervals seen by the kernel i.e. no adjustment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * for kernel's involuntary waits due to virtualization.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * Value is cumulative, in nanoseconds, without a corresponding count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * and wraps around to zero silently on overflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) __u64 cpu_run_virtual_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) /* Delay accounting fields end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) /* version 1 ends here */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 3) Extended accounting fields::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) /* Extended accounting fields start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) /* Accumulated RSS usage in duration of a task, in MBytes-usecs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * The current rss usage is added to this counter every time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) * a tick is charged to a task's system time. So, at the end we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * will have memory usage multiplied by system time. Thus an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * average usage per system time unit can be calculated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) __u64 coremem; /* accumulated RSS usage in MB-usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /* Accumulated virtual memory usage in duration of a task.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * Same as acct_rss_mem1 above except that we keep track of VM usage.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) __u64 virtmem; /* accumulated VM usage in MB-usec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /* High watermark of RSS usage in duration of a task, in KBytes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) __u64 hiwater_rss; /* High-watermark of RSS usage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) /* High watermark of VM usage in duration of a task, in KBytes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) __u64 hiwater_vm; /* High-water virtual memory usage */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /* The following four fields are I/O statistics of a task. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) __u64 read_char; /* bytes read */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) __u64 write_char; /* bytes written */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) __u64 read_syscalls; /* read syscalls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) __u64 write_syscalls; /* write syscalls */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) /* Extended accounting fields end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 4) Per-task and per-thread statistics::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) __u64 nvcsw; /* Context voluntary switch counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) __u64 nivcsw; /* Context involuntary switch counter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 5) Time accounting for SMT machines::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) __u64 ac_utimescaled; /* utime scaled on frequency etc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) __u64 ac_stimescaled; /* stime scaled on frequency etc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) __u64 cpu_scaled_run_real_total; /* scaled cpu_run_real_total */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 6) Extended delay accounting fields for memory reclaim::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) /* Delay waiting for memory reclaim */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) __u64 freepages_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) __u64 freepages_delay_total;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) }