]> granicus.if.org Git - procps-ng/commitdiff
top: add major/minor page fault deltas
authorJim Warner <james.warner@comcast.net>
Sun, 8 Jul 2012 09:02:58 +0000 (04:02 -0500)
committerCraig Small <csmall@enc.com.au>
Wed, 29 Aug 2012 07:37:29 +0000 (17:37 +1000)
Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c
top/top.h
top/top_nls.c

index c0bd22f291458c138f94babfaa69c353a964c2d9..c1fc717bdbe66612101ea3e98f54416e9a60dc2e 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -212,6 +212,8 @@ SCB_STRS(ENV, environ[0])
 SCB_NUM1(FLG, flags)
 SCB_NUM1(FL1, maj_flt)
 SCB_NUM1(FL2, min_flt)
+SCB_NUM1(FV1, maj_delta)
+SCB_NUM1(FV2, min_delta)
 SCB_NUMx(GID, egid)
 SCB_STRS(GRP, egroup)
 SCB_NUMx(NCE, nice)
@@ -1300,7 +1302,9 @@ static FLD_t Fieldstab[] = {
    { " Badness ",   "%8d ",      -1,     -1,  SF(OOM),  L_oom,     NULL },
 #undef L_oom
 #endif
-   { "ENVIRON  ",   NULL,        -1,     -1,  SF(ENV),  L_ENVIRON, NULL }
+   { "ENVIRON  ",   NULL,        -1,     -1,  SF(ENV),  L_ENVIRON, NULL },
+   { "vMj ",        "%3.3s ",     3,  SK_no,  SF(FV1),  L_stat,    NULL },
+   { "vMn ",        "%3.3s ",     3,  SK_no,  SF(FV2),  L_stat,    NULL }
  #undef SF
 };
 
@@ -2025,15 +2029,26 @@ static void procs_hlp (proc_t *this) {
       calcs and saves that go unused, like the old top! */
    PHist_new[Frame_maxtask].pid  = this->tid;
    PHist_new[Frame_maxtask].tics = tics = (this->utime + this->stime);
+   // finally, save major/minor fault counts in case the deltas are displayable
+   PHist_new[Frame_maxtask].maj = this->maj_flt;
+   PHist_new[Frame_maxtask].min = this->min_flt;
 
 #ifdef OFF_HST_HASH
-   // find matching entry from previous frame and make ticks elapsed
-   if ((h = hstbsrch(PHist_sav, maxt_sav - 1, this->tid))) tics -= h->tics;
+   // find matching entry from previous frame and make stuff elapsed
+   if ((h = hstbsrch(PHist_sav, maxt_sav - 1, this->tid))) {
+      tics -= h->tics;
+      this->maj_delta = this->maj_flt - h->maj;
+      this->min_delta = this->min_flt - h->min;
+   }
 #else
    // hash & save for the next frame
    hstput(Frame_maxtask);
-   // find matching entry from previous frame and make ticks elapsed
-   if ((h = hstget(this->tid))) tics -= h->tics;
+   // find matching entry from previous frame and make stuff elapsed
+   if ((h = hstget(this->tid))) {
+      tics -= h->tics;
+      this->maj_delta = this->maj_flt - h->maj;
+      this->min_delta = this->min_flt - h->min;
+   }
 #endif
 
    /* we're just saving elapsed tics, to be converted into %cpu if
@@ -3719,6 +3734,12 @@ static void task_show (const WIN_t *q, const proc_t *p, char *ptr) {
          case P_FL2:
             makeCOL(scale_num(p->min_flt, w, s));
             break;
+         case P_FV1:
+            makeCOL(scale_num(p->maj_delta, w, s));
+            break;
+         case P_FV2:
+            makeCOL(scale_num(p->min_delta, w, s));
+            break;
          case P_GID:
             makeCOL(p->egid);
             break;
index d7d2754e627ced045250173f95055746f58f47d7..4e71c8b2a69b11c955e86aed8690fca8bbf6570f 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -167,6 +167,7 @@ enum pflag {
    P_OOA, P_OOM,
 #endif
    P_ENV,
+   P_FV1, P_FV2,
 #ifdef USE_X_COLHDR
    // not really pflags, used with tbl indexing
    P_MAXPFLGS
@@ -205,23 +206,25 @@ typedef struct FLD_t {
 } FLD_t;
 
 #ifdef OFF_HST_HASH
-        /* This structure supports 'history' processing and ultimately records
-           one piece of critical information from one frame to the next --
+        /* This structure supports 'history' processing and records the
+           bare minimum of needed information from one frame to the next --
            we don't calc and save data that goes unused like the old top. */
 typedef struct HST_t {
    TIC_t tics;                  // last frame's tics count
-   int   pid;                   // record 'key'
+   unsigned long maj, min;      // last frame's maj/min_flt counts
+   int pid;                     // record 'key'
 } HST_t;
 #else
-        /* This structure supports 'history' processing and ultimately records
-           one piece of critical information from one frame to the next --
+        /* This structure supports 'history' processing and records the
+           bare minimum of needed information from one frame to the next --
            we don't calc and save data that goes unused like the old top nor
            do we incure the overhead of sorting to support a binary search
            (or worse, a friggin' for loop) when retrieval is necessary! */
 typedef struct HST_t {
    TIC_t tics;                  // last frame's tics count
-   int   pid;                   // record 'key'
-   int   lnk;                   // next on hash chain
+   unsigned long maj, min;      // last frame's maj/min_flt counts
+   int pid;                     // record 'key'
+   int lnk;                     // next on hash chain
 } HST_t;
 #endif
 
index fbd5899cb67a980a4d62c094041b367203785eb7..0526f8d7e33d2cc749ede2d1a75f196a8c92a1af 100644 (file)
@@ -150,6 +150,8 @@ static void build_desc_nlstab (void) {
 /* Translation Hint: The abbreviation 'vars' below is shorthand for
                      'variables' */
    Desc_nlstab[P_ENV] = _("Environment vars");
+   Desc_nlstab[P_FV1] = _("Major Faults delta");
+   Desc_nlstab[P_FV2] = _("Minor Faults delta");
 }