From ae8d63addbad3e7f26e3798b0766393156e44066 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Sun, 20 Jun 2021 00:00:00 -0500 Subject: [PATCH] top: follow ps lead & add several IO accounting fields Some time ago, IO accounting was added for the library and exploited by the ps program. This patch just plays a little catch-up & adds similar functionality to top. [ and we also finally get around to incrementing the ] [ rcfile id which should have already been done when ] [ the smaps fields were added or, at least, with USS ] Reference(s): . added IO accounting to ps program commit 8baf8eeab4d5cf4ce712f3a0048985fe045c87f7 . added IO accounting to library commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c Signed-off-by: Jim Warner --- top/top.c | 12 ++++++++++-- top/top.h | 3 ++- top/top_nls.c | 12 ++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/top/top.c b/top/top.c index 6fc79400..69b218b7 100644 --- a/top/top.c +++ b/top/top.c @@ -1677,8 +1677,12 @@ static struct { { 6, SK_Kb, A_right, PIDS_SMAP_PSS_ANON }, // ul_int EU_PZA { 6, SK_Kb, A_right, PIDS_SMAP_PSS_FILE }, // ul_int EU_PZF { 6, SK_Kb, A_right, PIDS_SMAP_PSS_SHMEM }, // ul_int EU_PZS - { 6, SK_Kb, A_right, PIDS_SMAP_PRV_TOTAL } // ul_int EU_USS -#define eu_LAST EU_USS + { 6, SK_Kb, A_right, PIDS_SMAP_PRV_TOTAL }, // ul_int EU_USS + { 6, -1, A_right, PIDS_IO_READ_BYTES }, // ul_int EU_IRB + { 5, -1, A_right, PIDS_IO_READ_OPS }, // ul_int EU_IRO + { 6, -1, A_right, PIDS_IO_WRITE_BYTES }, // ul_int EU_IWB + { 5, -1, A_right, PIDS_IO_WRITE_OPS } // ul_int EU_IWO +#define eu_LAST EU_IWO // xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . . . . . #define eu_CMDLINE eu_LAST +1 #define eu_TICS_ALL_C eu_LAST +2 @@ -5908,6 +5912,10 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) { /* ul_int, scale_num */ case EU_FL1: // PIDS_FLT_MAJ case EU_FL2: // PIDS_FLT_MIN + case EU_IRB: // PIDS_IO_READ_BYTES + case EU_IRO: // PIDS_IO_READ_OPS + case EU_IWB: // PIDS_IO_WRITE_BYTES + case EU_IWO: // PIDS_IO_WRITE_OPS cp = scale_num(rSv(i, ul_int), W, Jn); break; /* ul_int, scale_pcnt */ diff --git a/top/top.h b/top/top.h index f72aff1f..5ab5759b 100644 --- a/top/top.h +++ b/top/top.h @@ -190,6 +190,7 @@ enum pflag { EU_LID, EU_EXE, EU_RSS, EU_PSS, EU_PZA, EU_PZF, EU_PZS, EU_USS, + EU_IRB, EU_IRO, EU_IWB, EU_IWO, #ifdef USE_X_COLHDR // not really pflags, used with tbl indexing EU_MAXPFLGS @@ -485,7 +486,7 @@ typedef struct WIN_t { #define RCF_EYECATCHER "Config File (Linux processes with windows)\n" #define RCF_PLUS_H "\\]^_`abcdefghij" #define RCF_PLUS_J "klmnopqrstuvwxyz" -#define RCF_VERSION_ID 'j' +#define RCF_VERSION_ID 'k' /* The default fields displayed and their order, if nothing is specified by the loser, oops user. diff --git a/top/top_nls.c b/top/top_nls.c index e087a618..407665ec 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -332,6 +332,18 @@ static void build_two_nlstabs (void) { /* Translation Hint: maximum 'USS' = 6 */ Head_nlstab[EU_USS] = _("USS"); Desc_nlstab[EU_USS] = _("Unique RSS, KiB"); +/* Translation Hint: maximum 'ioR' = 6 */ + Head_nlstab[EU_IRB] = _("ioR"); + Desc_nlstab[EU_IRB] = _("I/O Bytes Read"); +/* Translation Hint: maximum 'ioRop' = 5 */ + Head_nlstab[EU_IRO] = _("ioRop"); + Desc_nlstab[EU_IRO] = _("I/O Read Operations"); +/* Translation Hint: maximum 'ioW' = 6 */ + Head_nlstab[EU_IWB] = _("ioW"); + Desc_nlstab[EU_IWB] = _("I/O Bytes Written"); +/* Translation Hint: maximum 'ioWop' = 5 */ + Head_nlstab[EU_IWO] = _("ioWop"); + Desc_nlstab[EU_IWO] = _("I/O Write Operations"); }