18c2ecf20Sopenharmony_ci==================== 28c2ecf20Sopenharmony_ciThe struct taskstats 38c2ecf20Sopenharmony_ci==================== 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ciThis document contains an explanation of the struct taskstats fields. 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciThere are three different groups of fields in the struct taskstats: 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci1) Common and basic accounting fields 108c2ecf20Sopenharmony_ci If CONFIG_TASKSTATS is set, the taskstats interface is enabled and 118c2ecf20Sopenharmony_ci the common fields and basic accounting fields are collected for 128c2ecf20Sopenharmony_ci delivery at do_exit() of a task. 138c2ecf20Sopenharmony_ci2) Delay accounting fields 148c2ecf20Sopenharmony_ci These fields are placed between:: 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci /* Delay accounting fields start */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci and:: 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci /* Delay accounting fields end */ 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci Their values are collected if CONFIG_TASK_DELAY_ACCT is set. 238c2ecf20Sopenharmony_ci3) Extended accounting fields 248c2ecf20Sopenharmony_ci These fields are placed between:: 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci /* Extended accounting fields start */ 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci and:: 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci /* Extended accounting fields end */ 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci Their values are collected if CONFIG_TASK_XACCT is set. 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci4) Per-task and per-thread context switch count statistics 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci5) Time accounting for SMT machines 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci6) Extended delay accounting fields for memory reclaim 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciFuture extension should add fields to the end of the taskstats struct, and 418c2ecf20Sopenharmony_cishould not change the relative position of each field within the struct. 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci:: 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci struct taskstats { 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci1) Common and basic accounting fields:: 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci /* The version number of this struct. This field is always set to 508c2ecf20Sopenharmony_ci * TAKSTATS_VERSION, which is defined in <linux/taskstats.h>. 518c2ecf20Sopenharmony_ci * Each time the struct is changed, the value should be incremented. 528c2ecf20Sopenharmony_ci */ 538c2ecf20Sopenharmony_ci __u16 version; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci /* The exit code of a task. */ 568c2ecf20Sopenharmony_ci __u32 ac_exitcode; /* Exit status */ 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci /* The accounting flags of a task as defined in <linux/acct.h> 598c2ecf20Sopenharmony_ci * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG. 608c2ecf20Sopenharmony_ci */ 618c2ecf20Sopenharmony_ci __u8 ac_flag; /* Record flags */ 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci /* The value of task_nice() of a task. */ 648c2ecf20Sopenharmony_ci __u8 ac_nice; /* task_nice */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci /* The name of the command that started this task. */ 678c2ecf20Sopenharmony_ci char ac_comm[TS_COMM_LEN]; /* Command name */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci /* The scheduling discipline as set in task->policy field. */ 708c2ecf20Sopenharmony_ci __u8 ac_sched; /* Scheduling discipline */ 718c2ecf20Sopenharmony_ci 728c2ecf20Sopenharmony_ci __u8 ac_pad[3]; 738c2ecf20Sopenharmony_ci __u32 ac_uid; /* User ID */ 748c2ecf20Sopenharmony_ci __u32 ac_gid; /* Group ID */ 758c2ecf20Sopenharmony_ci __u32 ac_pid; /* Process ID */ 768c2ecf20Sopenharmony_ci __u32 ac_ppid; /* Parent process ID */ 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci /* The time when a task begins, in [secs] since 1970. */ 798c2ecf20Sopenharmony_ci __u32 ac_btime; /* Begin time [sec since 1970] */ 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci /* The elapsed time of a task, in [usec]. */ 828c2ecf20Sopenharmony_ci __u64 ac_etime; /* Elapsed time [usec] */ 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci /* The user CPU time of a task, in [usec]. */ 858c2ecf20Sopenharmony_ci __u64 ac_utime; /* User CPU time [usec] */ 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci /* The system CPU time of a task, in [usec]. */ 888c2ecf20Sopenharmony_ci __u64 ac_stime; /* System CPU time [usec] */ 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci /* The minor page fault count of a task, as set in task->min_flt. */ 918c2ecf20Sopenharmony_ci __u64 ac_minflt; /* Minor Page Fault Count */ 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci /* The major page fault count of a task, as set in task->maj_flt. */ 948c2ecf20Sopenharmony_ci __u64 ac_majflt; /* Major Page Fault Count */ 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci2) Delay accounting fields:: 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci /* Delay accounting fields start 1008c2ecf20Sopenharmony_ci * 1018c2ecf20Sopenharmony_ci * All values, until the comment "Delay accounting fields end" are 1028c2ecf20Sopenharmony_ci * available only if delay accounting is enabled, even though the last 1038c2ecf20Sopenharmony_ci * few fields are not delays 1048c2ecf20Sopenharmony_ci * 1058c2ecf20Sopenharmony_ci * xxx_count is the number of delay values recorded 1068c2ecf20Sopenharmony_ci * xxx_delay_total is the corresponding cumulative delay in nanoseconds 1078c2ecf20Sopenharmony_ci * 1088c2ecf20Sopenharmony_ci * xxx_delay_total wraps around to zero on overflow 1098c2ecf20Sopenharmony_ci * xxx_count incremented regardless of overflow 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci /* Delay waiting for cpu, while runnable 1138c2ecf20Sopenharmony_ci * count, delay_total NOT updated atomically 1148c2ecf20Sopenharmony_ci */ 1158c2ecf20Sopenharmony_ci __u64 cpu_count; 1168c2ecf20Sopenharmony_ci __u64 cpu_delay_total; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci /* Following four fields atomically updated using task->delays->lock */ 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci /* Delay waiting for synchronous block I/O to complete 1218c2ecf20Sopenharmony_ci * does not account for delays in I/O submission 1228c2ecf20Sopenharmony_ci */ 1238c2ecf20Sopenharmony_ci __u64 blkio_count; 1248c2ecf20Sopenharmony_ci __u64 blkio_delay_total; 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci /* Delay waiting for page fault I/O (swap in only) */ 1278c2ecf20Sopenharmony_ci __u64 swapin_count; 1288c2ecf20Sopenharmony_ci __u64 swapin_delay_total; 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci /* cpu "wall-clock" running time 1318c2ecf20Sopenharmony_ci * On some architectures, value will adjust for cpu time stolen 1328c2ecf20Sopenharmony_ci * from the kernel in involuntary waits due to virtualization. 1338c2ecf20Sopenharmony_ci * Value is cumulative, in nanoseconds, without a corresponding count 1348c2ecf20Sopenharmony_ci * and wraps around to zero silently on overflow 1358c2ecf20Sopenharmony_ci */ 1368c2ecf20Sopenharmony_ci __u64 cpu_run_real_total; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci /* cpu "virtual" running time 1398c2ecf20Sopenharmony_ci * Uses time intervals seen by the kernel i.e. no adjustment 1408c2ecf20Sopenharmony_ci * for kernel's involuntary waits due to virtualization. 1418c2ecf20Sopenharmony_ci * Value is cumulative, in nanoseconds, without a corresponding count 1428c2ecf20Sopenharmony_ci * and wraps around to zero silently on overflow 1438c2ecf20Sopenharmony_ci */ 1448c2ecf20Sopenharmony_ci __u64 cpu_run_virtual_total; 1458c2ecf20Sopenharmony_ci /* Delay accounting fields end */ 1468c2ecf20Sopenharmony_ci /* version 1 ends here */ 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci3) Extended accounting fields:: 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci /* Extended accounting fields start */ 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci /* Accumulated RSS usage in duration of a task, in MBytes-usecs. 1548c2ecf20Sopenharmony_ci * The current rss usage is added to this counter every time 1558c2ecf20Sopenharmony_ci * a tick is charged to a task's system time. So, at the end we 1568c2ecf20Sopenharmony_ci * will have memory usage multiplied by system time. Thus an 1578c2ecf20Sopenharmony_ci * average usage per system time unit can be calculated. 1588c2ecf20Sopenharmony_ci */ 1598c2ecf20Sopenharmony_ci __u64 coremem; /* accumulated RSS usage in MB-usec */ 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci /* Accumulated virtual memory usage in duration of a task. 1628c2ecf20Sopenharmony_ci * Same as acct_rss_mem1 above except that we keep track of VM usage. 1638c2ecf20Sopenharmony_ci */ 1648c2ecf20Sopenharmony_ci __u64 virtmem; /* accumulated VM usage in MB-usec */ 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci /* High watermark of RSS usage in duration of a task, in KBytes. */ 1678c2ecf20Sopenharmony_ci __u64 hiwater_rss; /* High-watermark of RSS usage */ 1688c2ecf20Sopenharmony_ci 1698c2ecf20Sopenharmony_ci /* High watermark of VM usage in duration of a task, in KBytes. */ 1708c2ecf20Sopenharmony_ci __u64 hiwater_vm; /* High-water virtual memory usage */ 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_ci /* The following four fields are I/O statistics of a task. */ 1738c2ecf20Sopenharmony_ci __u64 read_char; /* bytes read */ 1748c2ecf20Sopenharmony_ci __u64 write_char; /* bytes written */ 1758c2ecf20Sopenharmony_ci __u64 read_syscalls; /* read syscalls */ 1768c2ecf20Sopenharmony_ci __u64 write_syscalls; /* write syscalls */ 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci /* Extended accounting fields end */ 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ci4) Per-task and per-thread statistics:: 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci __u64 nvcsw; /* Context voluntary switch counter */ 1838c2ecf20Sopenharmony_ci __u64 nivcsw; /* Context involuntary switch counter */ 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci5) Time accounting for SMT machines:: 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci __u64 ac_utimescaled; /* utime scaled on frequency etc */ 1888c2ecf20Sopenharmony_ci __u64 ac_stimescaled; /* stime scaled on frequency etc */ 1898c2ecf20Sopenharmony_ci __u64 cpu_scaled_run_real_total; /* scaled cpu_run_real_total */ 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci6) Extended delay accounting fields for memory reclaim:: 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci /* Delay waiting for memory reclaim */ 1948c2ecf20Sopenharmony_ci __u64 freepages_count; 1958c2ecf20Sopenharmony_ci __u64 freepages_delay_total; 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ci:: 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci } 200