June 2025 | ||||||
Mo | Tu | We | Th | Fr | Sa | Su |
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 1 | 2 | 3 | 4 | 5 | 6 |
001: /* taskstats.h - exporting per-task statistics 002: * 003: * Copyright (C) Shailabh Nagar, IBM Corp. 2006 004: * (C) Balbir Singh, IBM Corp. 2006 005: * (C) Jay Lan, SGI, 2006 006: * 007: * This program is free software; you can redistribute it and/or modify it 008: * under the terms of version 2.1 of the GNU Lesser General Public License 009: * as published by the Free Software Foundation. 010: * 011: * This program is distributed in the hope that it would be useful, but 012: * WITHOUT ANY WARRANTY; without even the implied warranty of 013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 014: */ 015: 016: #ifndef _LINUX_TASKSTATS_H 017: #define _LINUX_TASKSTATS_H 018: 019: #include <linux/types.h> 020: 021: /* Format for per-task data returned to userland when 022: * - a task exits 023: * - listener requests stats for a task 024: * 025: * The struct is versioned. Newer versions should only add fields to 026: * the bottom of the struct to maintain backward compatibility. 027: * 028: * 029: * To add new fields 030: * a) bump up TASKSTATS_VERSION 031: * b) add comment indicating new version number at end of struct 032: * c) add new fields after version comment; maintain 64-bit alignment 033: */ 034: 035: 036: #define TASKSTATS_VERSION 8 037: #define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN 038: * in linux/sched.h */ 039: 040: struct taskstats { 041: 042: /* The version number of this struct. This field is always set to 043: * TAKSTATS_VERSION, which is defined in <linux/taskstats.h>. 044: * Each time the struct is changed, the value should be incremented. 045: */ 046: __u16 version; 047: __u32 ac_exitcode; /* Exit status */ 048: 049: /* The accounting flags of a task as defined in <linux/acct.h> 050: * Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG. 051: */ 052: __u8 ac_flag; /* Record flags */ 053: __u8 ac_nice; /* task_nice */ 054: 055: /* Delay accounting fields start 056: * 057: * All values, until comment "Delay accounting fields end" are 058: * available only if delay accounting is enabled, even though the last 059: * few fields are not delays 060: * 061: * xxx_count is the number of delay values recorded 062: * xxx_delay_total is the corresponding cumulative delay in nanoseconds 063: * 064: * xxx_delay_total wraps around to zero on overflow 065: * xxx_count incremented regardless of overflow 066: */ 067: 068: /* Delay waiting for cpu, while runnable 069: * count, delay_total NOT updated atomically 070: */ 071: __u64 cpu_count __attribute__((aligned(8))); 072: __u64 cpu_delay_total; 073: 074: /* Following four fields atomically updated using task->delays->lock */ 075: 076: /* Delay waiting for synchronous block I/O to complete 077: * does not account for delays in I/O submission 078: */ 079: __u64 blkio_count; 080: __u64 blkio_delay_total; 081: 082: /* Delay waiting for page fault I/O (swap in only) */ 083: __u64 swapin_count; 084: __u64 swapin_delay_total; 085: 086: /* cpu "wall-clock" running time 087: * On some architectures, value will adjust for cpu time stolen 088: * from the kernel in involuntary waits due to virtualization. 089: * Value is cumulative, in nanoseconds, without a corresponding count 090: * and wraps around to zero silently on overflow 091: */ 092: __u64 cpu_run_real_total; 093: 094: /* cpu "virtual" running time 095: * Uses time intervals seen by the kernel i.e. no adjustment 096: * for kernel's involuntary waits due to virtualization. 097: * Value is cumulative, in nanoseconds, without a corresponding count 098: * and wraps around to zero silently on overflow 099: */ 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 */ 214: