]> granicus.if.org Git - procps-ng/commitdiff
top: exploit new linux-4.5 resident memory enhancement
authorJim Warner <james.warner@comcast.net>
Wed, 13 Apr 2016 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Tue, 7 Jun 2016 10:49:30 +0000 (20:49 +1000)
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>
top/top.c
top/top.h
top/top_nls.c

index e355747ff878a4938c18514a2add0ffc8601d4c5..09e2f0add95ebbcd7c772648939baff9c69dcd90 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -284,6 +284,10 @@ SCB_NUMx(PID, tid)
 SCB_NUMx(PPD, ppid)
 SCB_NUMx(PRI, priority)
 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_STRS(SGN, supgrp)
 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(NS5),  L_NS      }, // USERNS
    {    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 A_left
  #undef A_right
@@ -2316,7 +2331,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();
@@ -5426,6 +5443,18 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
          case EU_RES:
             cp = scale_mem(S, p->vm_rss, W, Jn);
             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:
             makeVAR(p->supgid);
             break;
index 789b9b3043feececa97b25110337fbc58e868735..ec3438ebded3d22a75a10d1440dc020006053df1 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -206,6 +206,7 @@ enum pflag {
    EU_USE,
    EU_NS1, EU_NS2, EU_NS3, EU_NS4, EU_NS5, EU_NS6,
    EU_LXC,
+   EU_RZA, EU_RZF, EU_RZL, EU_RZS,
 #ifdef USE_X_COLHDR
    // not really pflags, used with tbl indexing
    EU_MAXPFLGS
index 93e5619c9971f1a6d2412991a79f7262ac121f1e..1ac239fa246454462b1d87254bb3c9d22d0274f3 100644 (file)
@@ -280,6 +280,18 @@ static void build_two_nlstabs (void) {
 /* Translation Hint: maximum 'LXC' = 7 */
    Head_nlstab[EU_LXC] = _("LXC");
    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)");
 }