diff options
Diffstat (limited to 'include/uapi/linux/taskstats.h')
| -rw-r--r-- | include/uapi/linux/taskstats.h | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/include/uapi/linux/taskstats.h b/include/uapi/linux/taskstats.h new file mode 100644 index 000000000000..2466e550a41d --- /dev/null +++ b/include/uapi/linux/taskstats.h | |||
| @@ -0,0 +1,213 @@ | |||
| 1 | /* taskstats.h - exporting per-task statistics | ||
| 2 | * | ||
| 3 | * Copyright (C) Shailabh Nagar, IBM Corp. 2006 | ||
| 4 | * (C) Balbir Singh, IBM Corp. 2006 | ||
| 5 | * (C) Jay Lan, SGI, 2006 | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify it | ||
| 8 | * under the terms of version 2.1 of the GNU Lesser General Public License | ||
| 9 | * as published by the Free Software Foundation. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it would be useful, but | ||
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | */ | ||
| 15 | |||
| 16 | #ifndef _LINUX_TASKSTATS_H | ||
| 17 | #define _LINUX_TASKSTATS_H | ||
| 18 | |||
| 19 | #include <linux/types.h> | ||
| 20 | |||
| 21 | /* Format for per-task data returned to userland when | ||
| 22 | * - a task exits | ||
| 23 | * - listener requests stats for a task | ||
| 24 | * | ||
| 25 | * The struct is versioned. Newer versions should only add fields to | ||
| 26 | * the bottom of the struct to maintain backward compatibility. | ||
| 27 | * | ||
| 28 | * | ||
| 29 | * To add new fields | ||
| 30 | * a) bump up TASKSTATS_VERSION | ||
| 31 | * b) add comment indicating new version number at end of struct | ||
| 32 | * c) add new fields after version comment; maintain 64-bit alignment | ||
| 33 | */ | ||
| 34 | |||
| 35 | |||
| 36 | #define TASKSTATS_VERSION 8 | ||
| 37 | #define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN | ||
| 38 | * in linux/sched.h */ | ||
| 39 | |||
| 40 | struct taskstats { | ||
| 41 | |||
| 42 | /* The version number of this struct. This field is always set to | ||
| 43 | * TAKSTATS_VERSION, which is defined in <linux/taskstats.h>. | ||
| 44 | * Each time the struct is changed, the value should be incremented. | ||
| 45 | */ | ||
| 46 | __u16 version; | ||
| 47 | __u32 ac_exitcode; /* Exit status */ | ||
| 48 | |||
| 49 | /* The accounting flags of a task as defined in <linux/acct.h> | ||
| 50 | * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG. | ||
| 51 | */ | ||
| 52 | __u8 ac_flag; /* Record flags */ | ||
| 53 | __u8 ac_nice; /* task_nice */ | ||
| 54 | |||
| 55 | /* Delay accounting fields start | ||
| 56 | * | ||
| 57 | * All values, until comment "Delay accounting fields end" are | ||
| 58 | * available only if delay accounting is enabled, even though the last | ||
| 59 | * few fields are not delays | ||
| 60 | * | ||
| 61 | * xxx_count is the number of delay values recorded | ||
| 62 | * xxx_delay_total is the corresponding cumulative delay in nanoseconds | ||
| 63 | * | ||
| 64 | * xxx_delay_total wraps around to zero on overflow | ||
| 65 | * xxx_count incremented regardless of overflow | ||
| 66 | */ | ||
| 67 | |||
| 68 | /* Delay waiting for cpu, while runnable | ||
| 69 | * count, delay_total NOT updated atomically | ||
| 70 | */ | ||
| 71 | __u64 cpu_count __attribute__((aligned(8))); | ||
| 72 | __u64 cpu_delay_total; | ||
| 73 | |||
| 74 | /* Following four fields atomically updated using task->delays->lock */ | ||
| 75 | |||
| 76 | /* Delay waiting for synchronous block I/O to complete | ||
| 77 | * does not account for delays in I/O submission | ||
| 78 | */ | ||
| 79 | __u64 blkio_count; | ||
| 80 | __u64 blkio_delay_total; | ||
| 81 | |||
| 82 | /* Delay waiting for page fault I/O (swap in only) */ | ||
| 83 | __u64 swapin_count; | ||
| 84 | __u64 swapin_delay_total; | ||
| 85 | |||
| 86 | /* cpu "wall-clock" running time | ||
| 87 | * On some architectures, value will adjust for cpu time stolen | ||
| 88 | * from the kernel in involuntary waits due to virtualization. | ||
| 89 | * Value is cumulative, in nanoseconds, without a corresponding count | ||
| 90 | * and wraps around to zero silently on overflow | ||
| 91 | */ | ||
| 92 | __u64 cpu_run_real_total; | ||
| 93 | |||
| 94 | /* cpu "virtual" running time | ||
| 95 | * Uses time intervals seen by the kernel i.e. no adjustment | ||
| 96 | * for kernel's involuntary waits due to virtualization. | ||
| 97 | * Value is cumulative, in nanoseconds, without a corresponding count | ||
| 98 | * and wraps around to zero silently on overflow | ||
| 99 | */ | ||
| 100 | __u64 cpu_run_virtual_total; | ||
| 101 | /* Delay accounting fields end */ | ||
| 102 | /* version 1 ends here */ | ||
| 103 | |||
| 104 | /* Basic Accounting Fields start */ | ||
| 105 | char ac_comm[TS_COMM_LEN]; /* Command name */ | ||
| 106 | __u8 ac_sched __attribute__((aligned(8))); | ||
| 107 | /* Scheduling discipline */ | ||
| 108 | __u8 ac_pad[3]; | ||
| 109 | __u32 ac_uid __attribute__((aligned(8))); | ||
| 110 | /* User ID */ | ||
| 111 | __u32 ac_gid; /* Group ID */ | ||
| 112 | __u32 ac_pid; /* Process ID */ | ||
| 113 | __u32 ac_ppid; /* Parent process ID */ | ||
| 114 | __u32 ac_btime; /* Begin time [sec since 1970] */ | ||
| 115 | __u64 ac_etime __attribute__((aligned(8))); | ||
| 116 | /* Elapsed time [usec] */ | ||
| 117 | __u64 ac_utime; /* User CPU time [usec] */ | ||
| 118 | __u64 ac_stime; /* SYstem CPU time [usec] */ | ||
| 119 | __u64 ac_minflt; /* Minor Page Fault Count */ | ||
| 120 | __u64 ac_majflt; /* Major Page Fault Count */ | ||
| 121 | /* Basic Accounting Fields end */ | ||
| 122 | |||
| 123 | /* Extended accounting fields start */ | ||
| 124 | /* Accumulated RSS usage in duration of a task, in MBytes-usecs. | ||
| 125 | * The current rss usage is added to this counter every time | ||
| 126 | * a tick is charged to a task's system time. So, at the end we | ||
| 127 | * will have memory usage multiplied by system time. Thus an | ||
| 128 | * average usage per system time unit can be calculated. | ||
| 129 | */ | ||
| 130 | __u64 coremem; /* accumulated RSS usage in MB-usec */ | ||
| 131 | /* Accumulated virtual memory usage in duration of a task. | ||
| 132 | * Same as acct_rss_mem1 above except that we keep track of VM usage. | ||
| 133 | */ | ||
| 134 | __u64 virtmem; /* accumulated VM usage in MB-usec */ | ||
| 135 | |||
| 136 | /* High watermark of RSS and virtual memory usage in duration of | ||
| 137 | * a task, in KBytes. | ||
| 138 | */ | ||
| 139 | __u64 hiwater_rss; /* High-watermark of RSS usage, in KB */ | ||
| 140 | __u64 hiwater_vm; /* High-water VM usage, in KB */ | ||
| 141 | |||
| 142 | /* The following four fields are I/O statistics of a task. */ | ||
| 143 | __u64 read_char; /* bytes read */ | ||
| 144 | __u64 write_char; /* bytes written */ | ||
| 145 | __u64 read_syscalls; /* read syscalls */ | ||
| 146 | __u64 write_syscalls; /* write syscalls */ | ||
| 147 | /* Extended accounting fields end */ | ||
| 148 | |||
| 149 | #define TASKSTATS_HAS_IO_ACCOUNTING | ||
| 150 | /* Per-task storage I/O accounting starts */ | ||
| 151 | __u64 read_bytes; /* bytes of read I/O */ | ||
| 152 | __u64 write_bytes; /* bytes of write I/O */ | ||
| 153 | __u64 cancelled_write_bytes; /* bytes of cancelled write I/O */ | ||
| 154 | |||
| 155 | __u64 nvcsw; /* voluntary_ctxt_switches */ | ||
| 156 | __u64 nivcsw; /* nonvoluntary_ctxt_switches */ | ||
| 157 | |||
| 158 | /* time accounting for SMT machines */ | ||
| 159 | __u64 ac_utimescaled; /* utime scaled on frequency etc */ | ||
| 160 | __u64 ac_stimescaled; /* stime scaled on frequency etc */ | ||
| 161 | __u64 cpu_scaled_run_real_total; /* scaled cpu_run_real_total */ | ||
| 162 | |||
| 163 | /* Delay waiting for memory reclaim */ | ||
| 164 | __u64 freepages_count; | ||
| 165 | __u64 freepages_delay_total; | ||
| 166 | }; | ||
| 167 | |||
| 168 | |||
| 169 | /* | ||
| 170 | * Commands sent from userspace | ||
| 171 | * Not versioned. New commands should only be inserted at the enum's end | ||
| 172 | * prior to __TASKSTATS_CMD_MAX | ||
| 173 | */ | ||
| 174 | |||
| 175 | enum { | ||
| 176 | TASKSTATS_CMD_UNSPEC = 0, /* Reserved */ | ||
| 177 | TASKSTATS_CMD_GET, /* user->kernel request/get-response */ | ||
| 178 | TASKSTATS_CMD_NEW, /* kernel->user event */ | ||
| 179 | __TASKSTATS_CMD_MAX, | ||
| 180 | }; | ||
| 181 | |||
| 182 | #define TASKSTATS_CMD_MAX (__TASKSTATS_CMD_MAX - 1) | ||
| 183 | |||
| 184 | enum { | ||
| 185 | TASKSTATS_TYPE_UNSPEC = 0, /* Reserved */ | ||
| 186 | TASKSTATS_TYPE_PID, /* Process id */ | ||
| 187 | TASKSTATS_TYPE_TGID, /* Thread group id */ | ||
| 188 | TASKSTATS_TYPE_STATS, /* taskstats structure */ | ||
| 189 | TASKSTATS_TYPE_AGGR_PID, /* contains pid + stats */ | ||
| 190 | TASKSTATS_TYPE_AGGR_TGID, /* contains tgid + stats */ | ||
| 191 | TASKSTATS_TYPE_NULL, /* contains nothing */ | ||
| 192 | __TASKSTATS_TYPE_MAX, | ||
| 193 | }; | ||
| 194 | |||
| 195 | #define TASKSTATS_TYPE_MAX (__TASKSTATS_TYPE_MAX - 1) | ||
| 196 | |||
| 197 | enum { | ||
| 198 | TASKSTATS_CMD_ATTR_UNSPEC = 0, | ||
| 199 | TASKSTATS_CMD_ATTR_PID, | ||
| 200 | TASKSTATS_CMD_ATTR_TGID, | ||
| 201 | TASKSTATS_CMD_ATTR_REGISTER_CPUMASK, | ||
| 202 | TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK, | ||
| 203 | __TASKSTATS_CMD_ATTR_MAX, | ||
| 204 | }; | ||
| 205 | |||
| 206 | #define TASKSTATS_CMD_ATTR_MAX (__TASKSTATS_CMD_ATTR_MAX - 1) | ||
| 207 | |||
| 208 | /* NETLINK_GENERIC related info */ | ||
| 209 | |||
| 210 | #define TASKSTATS_GENL_NAME "TASKSTATS" | ||
| 211 | #define TASKSTATS_GENL_VERSION 0x1 | ||
| 212 | |||
| 213 | #endif /* _LINUX_TASKSTATS_H */ | ||
