top: exploit new linux-4.5 resident memory enhancement

Since support already exists in the newlib branch this
represents an equivalent master branch implementation,
and this commit message is shared with 2 more patches.

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

p.s. Locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

p.p.s. Archlinux, Debian-stretch and Fedora-23 already
are currently using a 4.5 linux kernel (as of 6/2/16).

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 cb0e210930
commit 6306050a65
3 changed files with 44 additions and 2 deletions

View File

@ -284,6 +284,10 @@ SCB_NUMx(PID, tid)
SCB_NUMx(PPD, ppid) SCB_NUMx(PPD, ppid)
SCB_NUMx(PRI, priority) SCB_NUMx(PRI, priority)
SCB_NUM1(RES, vm_rss) // also serves MEM ! SCB_NUM1(RES, vm_rss) // also serves MEM !
SCB_NUM1(RZA, vm_rss_anon)
SCB_NUM1(RZF, vm_rss_file)
SCB_NUM1(RZL, vm_lock)
SCB_NUM1(RZS, vm_rss_shared)
SCB_STRX(SGD, supgid) SCB_STRX(SGD, supgid)
SCB_STRS(SGN, supgrp) SCB_STRS(SGN, supgrp)
SCB_NUM1(SHR, share) SCB_NUM1(SHR, share)
@ -1776,7 +1780,18 @@ static FLD_t Fieldstab[] = {
{ 10, -1, A_right, SF(NS4), L_NS }, // PIDNS { 10, -1, A_right, SF(NS4), L_NS }, // PIDNS
{ 10, -1, A_right, SF(NS5), L_NS }, // USERNS { 10, -1, A_right, SF(NS5), L_NS }, // USERNS
{ 10, -1, A_right, SF(NS6), L_NS }, // UTSNS { 10, -1, A_right, SF(NS6), L_NS }, // UTSNS
{ 8, -1, A_left, SF(LXC), L_LXC } { 8, -1, A_left, SF(LXC), L_LXC },
#ifndef NOBOOST_MEMS
{ 6, SK_Kb, A_right, SF(RZA), L_status },
{ 6, SK_Kb, A_right, SF(RZF), L_status },
{ 6, SK_Kb, A_right, SF(RZL), L_status },
{ 6, SK_Kb, A_right, SF(RZS), L_status }
#else
{ 4, SK_Kb, A_right, SF(RZA), L_status },
{ 4, SK_Kb, A_right, SF(RZF), L_status },
{ 4, SK_Kb, A_right, SF(RZL), L_status },
{ 4, SK_Kb, A_right, SF(RZS), L_status }
#endif
#undef SF #undef SF
#undef A_left #undef A_left
#undef A_right #undef A_right
@ -2316,7 +2331,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();
@ -5426,6 +5443,18 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
case EU_RES: case EU_RES:
cp = scale_mem(S, p->vm_rss, W, Jn); cp = scale_mem(S, p->vm_rss, W, Jn);
break; break;
case EU_RZA:
cp = scale_mem(S, p->vm_rss_anon, W, Jn);
break;
case EU_RZF:
cp = scale_mem(S, p->vm_rss_file, W, Jn);
break;
case EU_RZL:
cp = scale_mem(S, p->vm_lock, W, Jn);
break;
case EU_RZS:
cp = scale_mem(S, p->vm_rss_shared, W, Jn);
break;
case EU_SGD: case EU_SGD:
makeVAR(p->supgid); makeVAR(p->supgid);
break; break;

View File

@ -206,6 +206,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_LXC,
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

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