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