top: exploit new linux-4.5 resident memory enhancement

Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/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 1f8e41d019

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2016-04-13 00:00:00 -05:00 committed by Craig Small
parent 8dc378f6a8
commit 46458ab6b7
3 changed files with 32 additions and 2 deletions

View File

@ -1577,7 +1577,18 @@ static struct {
{ 10, -1, A_right, -1, PROCPS_PIDS_NS_UTS }, // ul_int EU_NS6 { 10, -1, A_right, -1, PROCPS_PIDS_NS_UTS }, // ul_int EU_NS6
{ 8, -1, A_left, -1, PROCPS_PIDS_LXCNAME }, // str EU_LXC { 8, -1, A_left, -1, PROCPS_PIDS_LXCNAME }, // str EU_LXC
{ -1, -1, A_left, -1, PROCPS_PIDS_CGNAME }, // str EU_CGN { -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 . . . ---------------------------------- // xtra Fieldstab 'pseudo pflag' entries for the newlib interface . . . ----------------------------------
#define eu_CMDLINE eu_LAST +1 #define eu_CMDLINE eu_LAST +1
#define eu_TICS_ALL_C eu_LAST +2 #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_VRT].scale = Fieldstab[EU_SWP].scale
= Fieldstab[EU_RES].scale = Fieldstab[EU_COD].scale = Fieldstab[EU_RES].scale = Fieldstab[EU_COD].scale
= Fieldstab[EU_DAT].scale = Fieldstab[EU_SHR].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... // lastly, ensure we've got proper column headers...
calibrate_fields(); calibrate_fields();
@ -5020,6 +5033,10 @@ static const char *task_show (const WIN_t *q, struct pids_stack *p) {
case EU_DAT: case EU_DAT:
case EU_DRT: // really # pgs & sl_int, but always zero since 2.6 case EU_DRT: // really # pgs & sl_int, but always zero since 2.6
case EU_RES: case EU_RES:
case EU_RZA:
case EU_RZF:
case EU_RZL:
case EU_RZS:
case EU_SHR: case EU_SHR:
case EU_SWP: case EU_SWP:
case EU_USE: case EU_USE:

View File

@ -185,6 +185,7 @@ enum pflag {
EU_USE, EU_USE,
EU_NS1, EU_NS2, EU_NS3, EU_NS4, EU_NS5, EU_NS6, EU_NS1, EU_NS2, EU_NS3, EU_NS4, EU_NS5, EU_NS6,
EU_LXC, EU_CGN, EU_LXC, EU_CGN,
EU_RZA, EU_RZF, EU_RZL, EU_RZS,
#ifdef USE_X_COLHDR #ifdef USE_X_COLHDR
// not really pflags, used with tbl indexing // not really pflags, used with tbl indexing
EU_MAXPFLGS EU_MAXPFLGS

View File

@ -281,6 +281,18 @@ static void build_two_nlstabs (void) {
/* Translation Hint: maximum 'CGNAME' = 7 */ /* Translation Hint: maximum 'CGNAME' = 7 */
Head_nlstab[EU_CGN] = _("CGNAME"); Head_nlstab[EU_CGN] = _("CGNAME");
Desc_nlstab[EU_CGN] = _("Control Group name"); 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)");
} }