]> granicus.if.org Git - procps-ng/commitdiff
ps: Add IO Accounting fields
authorCraig Small <csmall@dropbear.xyz>
Sat, 24 Apr 2021 13:13:38 +0000 (23:13 +1000)
committerCraig Small <csmall@dropbear.xyz>
Sat, 24 Apr 2021 13:13:38 +0000 (23:13 +1000)
Add the fields for the IO accounting to ps as the library now
has them added from previous commit.

References:
 commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

ps/common.h
ps/global.c
ps/output.c
ps/ps.1

index d0abca367f518d8904fcea997d38c5eb1a15a318..092299ef5c7e835234b109075d76d1226d097c78 100644 (file)
@@ -107,6 +107,13 @@ makEXT(ID_SUID)
 makEXT(ID_SUSER)
 makEXT(ID_TGID)
 makEXT(ID_TPGID)
+makEXT(IO_READ_BYTES)
+makEXT(IO_READ_CHARS)
+makEXT(IO_READ_OPS)
+makEXT(IO_WRITE_BYTES)
+makEXT(IO_WRITE_CBYTES)
+makEXT(IO_WRITE_CHARS)
+makEXT(IO_WRITE_OPS)
 makEXT(LXCNAME)
 makEXT(NICE)
 makEXT(NLWP)
index 601aff3cba627986261a1af84878b42e4a568b59..8ce95b03fda6892fa5c94061883a55a2f511d74c 100644 (file)
@@ -94,6 +94,13 @@ makREL(ID_SUID)
 makREL(ID_SUSER)
 makREL(ID_TGID)
 makREL(ID_TPGID)
+makREL(IO_READ_BYTES)
+makREL(IO_READ_CHARS)
+makREL(IO_READ_OPS)
+makREL(IO_WRITE_BYTES)
+makREL(IO_WRITE_CBYTES)
+makREL(IO_WRITE_CHARS)
+makREL(IO_WRITE_OPS)
 makREL(LXCNAME)
 makREL(NICE)
 makREL(NLWP)
index 1c6351e12af67da886366ba03d0ea4ef01b3a012..867c9a690eeaf99186fee7ebe989f7b086a86020 100644 (file)
@@ -1232,6 +1232,38 @@ setREL2(ID_SGROUP,ID_SGID)
 
 //////////////////////////////////////////////////////////////////////////////////
 
+// IO stats
+static int pr_rbytes(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(IO_READ_BYTES)
+  return snprintf(outbuf, COLWID, "%lu", rSv(IO_READ_BYTES, ul_int, pp));
+}
+static int pr_rchars(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(IO_READ_CHARS)
+  return snprintf(outbuf, COLWID, "%lu", rSv(IO_READ_CHARS, ul_int, pp));
+}
+static int pr_rops(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(IO_READ_OPS)
+  return snprintf(outbuf, COLWID, "%lu", rSv(IO_READ_OPS, ul_int, pp));
+}
+static int pr_wbytes(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(IO_WRITE_BYTES)
+  return snprintf(outbuf, COLWID, "%lu", rSv(IO_WRITE_BYTES, ul_int, pp));
+}
+static int pr_wcbytes(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(IO_WRITE_CBYTES)
+  return snprintf(outbuf, COLWID, "%lu", rSv(IO_WRITE_CBYTES, ul_int, pp));
+}
+static int pr_wchars(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(IO_WRITE_CHARS)
+  return snprintf(outbuf, COLWID, "%lu", rSv(IO_WRITE_CHARS, ul_int, pp));
+}
+static int pr_wops(char *restrict const outbuf, const proc_t *restrict const pp){
+setREL1(IO_WRITE_OPS)
+  return snprintf(outbuf, COLWID, "%lu", rSv(IO_WRITE_OPS, ul_int, pp));
+}
+
+//////////////////////////////////////////////////////////////////////////////////
+
 // PID pid, TGID tgid
 static int pr_procs(char *restrict const outbuf, const proc_t *restrict const pp){
 setREL1(ID_TGID)
@@ -1676,11 +1708,14 @@ static const format_struct format_array[] = { /*
 {"pset",      "PSET",    pr_nop,           PIDS_noop,                4,    DEC,  TO|RIGHT},
 {"psr",       "PSR",     pr_psr,           PIDS_PROCESSOR,           3,    DEC,  TO|RIGHT},
 {"psxpri",    "PPR",     pr_nop,           PIDS_noop,                3,    DEC,  TO|RIGHT},
+{"rbytes",    "RBYTES",  pr_rbytes,        PIDS_IO_READ_BYTES,       5,    LNX,  TO|RIGHT},
+{"rchars",    "RCHARS",  pr_rchars,        PIDS_IO_READ_CHARS,       5,    LNX,  TO|RIGHT},
 {"re",        "RE",      pr_nop,           PIDS_noop,                3,    BSD,  AN|RIGHT},
 {"resident",  "RES",     pr_nop,           PIDS_MEM_RES_PGS,         5,    LNX,  PO|RIGHT},
 {"rgid",      "RGID",    pr_rgid,          PIDS_ID_RGID,             5,    XXX,  ET|RIGHT},
 {"rgroup",    "RGROUP",  pr_rgroup,        PIDS_ID_RGROUP,           8,    U98,  ET|USER},  /* was 8 wide */
 {"rlink",     "RLINK",   pr_nop,           PIDS_noop,                8,    BSD,  AN|RIGHT},
+{"rops",      "ROPS",    pr_rops,          PIDS_IO_READ_OPS,         5,    LNX,  TO|RIGHT},
 {"rss",       "RSS",     pr_rss,           PIDS_VM_RSS,              5,    XXX,  PO|RIGHT}, /* was 5 wide */
 {"rssize",    "RSS",     pr_rss,           PIDS_VM_RSS,              5,    DEC,  PO|RIGHT}, /*rsz*/
 {"rsz",       "RSZ",     pr_rss,           PIDS_VM_RSS,              5,    BSD,  PO|RIGHT}, /*rssize*/
@@ -1778,8 +1813,12 @@ static const format_struct format_array[] = { /*
 {"vm_stack",  "STACK",   pr_nop,           PIDS_VM_STACK,            5,    LNx,  PO|RIGHT},
 {"vsize",     "VSZ",     pr_vsz,           PIDS_VSIZE_PGS,           6,    DEC,  PO|RIGHT}, /*vsz*/
 {"vsz",       "VSZ",     pr_vsz,           PIDS_VM_SIZE,             6,    U98,  PO|RIGHT}, /*vsize*/
+{"wbytes",    "WBYTES",  pr_wbytes,        PIDS_IO_WRITE_BYTES,      5,    LNX,  TO|RIGHT},
+{"wcbytes",   "WCBYTES", pr_wcbytes,       PIDS_IO_WRITE_CBYTES,     5,    LNX,  TO|RIGHT},
 {"wchan",     "WCHAN",   pr_wchan,         PIDS_WCHAN_NAME,          6,    XXX,  TO|WCHAN}, /* BSD n forces this to nwchan */ /* was 10 wide */
+{"wchars",    "WCHARS",  pr_wchars,        PIDS_IO_WRITE_CHARS,      5,    LNX,  TO|RIGHT},
 {"wname",     "WCHAN",   pr_wchan,         PIDS_WCHAN_NAME,          6,    SGI,  TO|WCHAN}, /* opposite of nwchan */
+{"wops",      "WOPS",    pr_wops,          PIDS_IO_WRITE_OPS,        5,    LNX,  TO|RIGHT},
 {"xstat",     "XSTAT",   pr_nop,           PIDS_noop,                5,    BSD,  AN|RIGHT},
 {"zone",      "ZONE",    pr_context,       PIDS_ID_TGID,            31,    SUN,  ET|LEFT},  // Solaris zone == Linux context?
 {"zoneid",    "ZONEID",  pr_nop,           PIDS_noop,               31,    SUN,  ET|RIGHT}, // Linux only offers context names
diff --git a/ps/ps.1 b/ps/ps.1
index b433655f9fa37cd80cca8a2f0c2d88495da04ab5..5c0d9d4e5141f0a5ce10713d136df8bd52671049 100644 (file)
--- a/ps/ps.1
+++ b/ps/ps.1
@@ -1524,6 +1524,14 @@ psr      PSR     T{
 processor that process last executed on.
 T}
 
+rbytes RBYTES  T{
+Number of bytes which this process really did cause to be fetched from the storage layer.
+T}
+
+rchars RCHARS  T{
+Number of bytes which this task has caused to be read from storage.
+T}
+
 rgid   RGID    T{
 real group ID.
 T}
@@ -1533,6 +1541,11 @@ real group name.  This will be the textual group ID, if it can be obtained
 and the field width permits, or a decimal representation otherwise.
 T}
 
+rops   ROPS    T{
+Number of read I/O operations—that is, system calls such as
+.BR read "(2) and " pread (2).
+T}
+
 rss    RSS     T{
 resident set size, the non\-swapped physical memory that a task has used (in
 kiloBytes).  (alias
@@ -1866,10 +1879,27 @@ mappings are currently excluded; this is subject to change.  (alias
 .BR vsize ).
 T}
 
+wbytes WBYTES  T{
+Number of bytes which this process caused to be sent to the storage layer.
+T}
+
+wcbytes        WCBYTES T{
+Number of cancelled write bytes.
+T}
+
 wchan  WCHAN   T{
 name of the kernel function in which the process is sleeping.
 T}
 
+wchars WCHARS  T{
+Number of bytes which this task has caused, or shall cause to be written to disk.
+T}
+
+wops   WOPS    T{
+Number of write I/O operations—that is, system calls such as
+.BR write "(2) and " pwrite (2).
+T}
+
 .TE
 .\" #######################################################################
 .PP