Path: blob/master/Documentation/accounting/taskstats-struct.txt
10821 views
The struct taskstats1--------------------23This document contains an explanation of the struct taskstats fields.45There are three different groups of fields in the struct taskstats:671) Common and basic accounting fields8If CONFIG_TASKSTATS is set, the taskstats interface is enabled and9the common fields and basic accounting fields are collected for10delivery at do_exit() of a task.112) Delay accounting fields12These fields are placed between13/* Delay accounting fields start */14and15/* Delay accounting fields end */16Their values are collected if CONFIG_TASK_DELAY_ACCT is set.173) Extended accounting fields18These fields are placed between19/* Extended accounting fields start */20and21/* Extended accounting fields end */22Their values are collected if CONFIG_TASK_XACCT is set.23244) Per-task and per-thread context switch count statistics25265) Time accounting for SMT machines27286) Extended delay accounting fields for memory reclaim2930Future extension should add fields to the end of the taskstats struct, and31should not change the relative position of each field within the struct.323334struct taskstats {35361) Common and basic accounting fields:37/* The version number of this struct. This field is always set to38* TAKSTATS_VERSION, which is defined in <linux/taskstats.h>.39* Each time the struct is changed, the value should be incremented.40*/41__u16 version;4243/* The exit code of a task. */44__u32 ac_exitcode; /* Exit status */4546/* The accounting flags of a task as defined in <linux/acct.h>47* Defined values are AFORK, ASU, ACOMPAT, ACORE, and AXSIG.48*/49__u8 ac_flag; /* Record flags */5051/* The value of task_nice() of a task. */52__u8 ac_nice; /* task_nice */5354/* The name of the command that started this task. */55char ac_comm[TS_COMM_LEN]; /* Command name */5657/* The scheduling discipline as set in task->policy field. */58__u8 ac_sched; /* Scheduling discipline */5960__u8 ac_pad[3];61__u32 ac_uid; /* User ID */62__u32 ac_gid; /* Group ID */63__u32 ac_pid; /* Process ID */64__u32 ac_ppid; /* Parent process ID */6566/* The time when a task begins, in [secs] since 1970. */67__u32 ac_btime; /* Begin time [sec since 1970] */6869/* The elapsed time of a task, in [usec]. */70__u64 ac_etime; /* Elapsed time [usec] */7172/* The user CPU time of a task, in [usec]. */73__u64 ac_utime; /* User CPU time [usec] */7475/* The system CPU time of a task, in [usec]. */76__u64 ac_stime; /* System CPU time [usec] */7778/* The minor page fault count of a task, as set in task->min_flt. */79__u64 ac_minflt; /* Minor Page Fault Count */8081/* The major page fault count of a task, as set in task->maj_flt. */82__u64 ac_majflt; /* Major Page Fault Count */8384852) Delay accounting fields:86/* Delay accounting fields start87*88* All values, until the comment "Delay accounting fields end" are89* available only if delay accounting is enabled, even though the last90* few fields are not delays91*92* xxx_count is the number of delay values recorded93* xxx_delay_total is the corresponding cumulative delay in nanoseconds94*95* xxx_delay_total wraps around to zero on overflow96* xxx_count incremented regardless of overflow97*/9899/* Delay waiting for cpu, while runnable100* count, delay_total NOT updated atomically101*/102__u64 cpu_count;103__u64 cpu_delay_total;104105/* Following four fields atomically updated using task->delays->lock */106107/* Delay waiting for synchronous block I/O to complete108* does not account for delays in I/O submission109*/110__u64 blkio_count;111__u64 blkio_delay_total;112113/* Delay waiting for page fault I/O (swap in only) */114__u64 swapin_count;115__u64 swapin_delay_total;116117/* cpu "wall-clock" running time118* On some architectures, value will adjust for cpu time stolen119* from the kernel in involuntary waits due to virtualization.120* Value is cumulative, in nanoseconds, without a corresponding count121* and wraps around to zero silently on overflow122*/123__u64 cpu_run_real_total;124125/* cpu "virtual" running time126* Uses time intervals seen by the kernel i.e. no adjustment127* for kernel's involuntary waits due to virtualization.128* Value is cumulative, in nanoseconds, without a corresponding count129* and wraps around to zero silently on overflow130*/131__u64 cpu_run_virtual_total;132/* Delay accounting fields end */133/* version 1 ends here */1341351363) Extended accounting fields137/* Extended accounting fields start */138139/* Accumulated RSS usage in duration of a task, in MBytes-usecs.140* The current rss usage is added to this counter every time141* a tick is charged to a task's system time. So, at the end we142* will have memory usage multiplied by system time. Thus an143* average usage per system time unit can be calculated.144*/145__u64 coremem; /* accumulated RSS usage in MB-usec */146147/* Accumulated virtual memory usage in duration of a task.148* Same as acct_rss_mem1 above except that we keep track of VM usage.149*/150__u64 virtmem; /* accumulated VM usage in MB-usec */151152/* High watermark of RSS usage in duration of a task, in KBytes. */153__u64 hiwater_rss; /* High-watermark of RSS usage */154155/* High watermark of VM usage in duration of a task, in KBytes. */156__u64 hiwater_vm; /* High-water virtual memory usage */157158/* The following four fields are I/O statistics of a task. */159__u64 read_char; /* bytes read */160__u64 write_char; /* bytes written */161__u64 read_syscalls; /* read syscalls */162__u64 write_syscalls; /* write syscalls */163164/* Extended accounting fields end */1651664) Per-task and per-thread statistics167__u64 nvcsw; /* Context voluntary switch counter */168__u64 nivcsw; /* Context involuntary switch counter */1691705) Time accounting for SMT machines171__u64 ac_utimescaled; /* utime scaled on frequency etc */172__u64 ac_stimescaled; /* stime scaled on frequency etc */173__u64 cpu_scaled_run_real_total; /* scaled cpu_run_real_total */1741756) Extended delay accounting fields for memory reclaim176/* Delay waiting for memory reclaim */177__u64 freepages_count;178__u64 freepages_delay_total;179}180181182