From 46458ab6b70a0eb85ba0e519d39f49418ebf3ba3 Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Wed, 13 Apr 2016 00:00:00 -0500 Subject: [PATCH] top: exploit new linux-4.5 resident memory enhancement Beginning with linux-4.5, the following new fields are being added under that /proc//status pseudo file: . RssAnon - size of resident anonymous memory . RssFile - size of resident file mappings . RssShmem - size of resident shared memory This patch just represents the initial library and top support, sharing a commit message with 2 more patches. p.s. locked resident memory support was also added but isn't directly related to the kernel 4.5 enhancements. Reference(s): commit 1f8e41d01966ef337bc252bffb181d0acc0c8751 Signed-off-by: Jim Warner --- top/top.c | 21 +++++++++++++++++++-- top/top.h | 1 + top/top_nls.c | 12 ++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/top/top.c b/top/top.c index d649e4b7..98615bea 100644 --- a/top/top.c +++ b/top/top.c @@ -1577,7 +1577,18 @@ static struct { { 10, -1, A_right, -1, PROCPS_PIDS_NS_UTS }, // ul_int EU_NS6 { 8, -1, A_left, -1, PROCPS_PIDS_LXCNAME }, // str EU_LXC { -1, -1, A_left, -1, PROCPS_PIDS_CGNAME }, // str EU_CGN -#define eu_LAST EU_CGN // ( the last real pflag, currently ) +#ifndef NOBOOST_MEMS + { 6, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_ANON }, // ul_int EU_RZA + { 6, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_FILE }, // ul_int EU_RZF + { 6, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_LOCKED }, // ul_int EU_RZL + { 6, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_SHARED }, // ul_int EU_RZS +#else + { 4, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_ANON }, // ul_int EU_RZA + { 4, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_FILE }, // ul_int EU_RZF + { 4, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_LOCKED }, // ul_int EU_RZL + { 4, SK_Kb, A_right, -1, PROCPS_PIDS_VM_RSS_SHARED }, // ul_int EU_RZS +#endif +#define eu_LAST EU_RZS // ( the last real pflag, currently ) // xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . ---------------------------------- #define eu_CMDLINE eu_LAST +1 #define eu_TICS_ALL_C eu_LAST +2 @@ -2150,7 +2161,9 @@ static void zap_fieldstab (void) { Fieldstab[EU_VRT].scale = Fieldstab[EU_SWP].scale = Fieldstab[EU_RES].scale = Fieldstab[EU_COD].scale = Fieldstab[EU_DAT].scale = Fieldstab[EU_SHR].scale - = Fieldstab[EU_USE].scale = Rc.task_mscale; + = Fieldstab[EU_USE].scale = Fieldstab[EU_RZA].scale + = Fieldstab[EU_RZF].scale = Fieldstab[EU_RZL].scale + = Fieldstab[EU_RZS].scale = Rc.task_mscale; // lastly, ensure we've got proper column headers... calibrate_fields(); @@ -5020,6 +5033,10 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) { case EU_DAT: case EU_DRT: // really # pgs & sl_int, but always zero since 2.6 case EU_RES: + case EU_RZA: + case EU_RZF: + case EU_RZL: + case EU_RZS: case EU_SHR: case EU_SWP: case EU_USE: diff --git a/top/top.h b/top/top.h index 22a14ee5..fed717e7 100644 --- a/top/top.h +++ b/top/top.h @@ -185,6 +185,7 @@ enum pflag { EU_USE, EU_NS1, EU_NS2, EU_NS3, EU_NS4, EU_NS5, EU_NS6, EU_LXC, EU_CGN, + EU_RZA, EU_RZF, EU_RZL, EU_RZS, #ifdef USE_X_COLHDR // not really pflags, used with tbl indexing EU_MAXPFLGS diff --git a/top/top_nls.c b/top/top_nls.c index 0397e512..3e25c746 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -281,6 +281,18 @@ static void build_two_nlstabs (void) { /* Translation Hint: maximum 'CGNAME' = 7 */ Head_nlstab[EU_CGN] = _("CGNAME"); Desc_nlstab[EU_CGN] = _("Control Group name"); +/* Translation Hint: maximum 'RSan' = 4 */ + Head_nlstab[EU_RZA] = _("RSan"); + Desc_nlstab[EU_RZA] = _("RES Anonymous (KiB)"); +/* Translation Hint: maximum 'RSfd' = 4 */ + Head_nlstab[EU_RZF] = _("RSfd"); + Desc_nlstab[EU_RZF] = _("RES File-based (KiB)"); +/* Translation Hint: maximum 'RSlk' = 4 */ + Head_nlstab[EU_RZL] = _("RSlk"); + Desc_nlstab[EU_RZL] = _("RES Locked (KiB)"); +/* Translation Hint: maximum 'RSsh' = 4 */ + Head_nlstab[EU_RZS] = _("RSsh"); + Desc_nlstab[EU_RZS] = _("RES Shared (KiB)"); }