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