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