]> granicus.if.org Git - procps-ng/commitdiff
Fixed per-process swap information in top and related cleanup.
authorJan Görig <jgorig@redhat.com>
Thu, 2 Jun 2011 10:15:14 +0000 (12:15 +0200)
committerJan Görig <jgorig@redhat.com>
Thu, 2 Jun 2011 10:15:14 +0000 (12:15 +0200)
Thanks to KOSAKI Motohiro and Jim.

Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=532668

top.1
top.c
top.h

diff --git a/top.1 b/top.1
index 51e27338ced13c56053a487109aff74a29945063..6e9b2d8ee5d3546a908569db3a169ea20b167ef4 100644 (file)
--- a/top.1
+++ b/top.1
@@ -625,8 +625,6 @@ The\fI saved\fR user name.
 28.\fB SWAP \*(Em Swapped Size (kb) \fR
 The non-resident portion of a task's address space.
 
-SWAP = VIRT - RES.
-
 .TP 4
 29.\fB TIME \*(Em \*(PU Time \fR
 Total \*(PU time the task has used since it started.
@@ -669,8 +667,6 @@ The total amount of \*(MV used by the task.
 It includes all code, data and shared libraries plus pages that have been
 swapped out and pages that have been mapped but not used.
 
-VIRT = SWAP + RES.
-
 .TP 4
 36.\fB WCHAN \*(Em Sleeping in Function \fR
 Depending on the availability of the kernel link map ('System.map'), this
diff --git a/top.c b/top.c
index b9e5e8696d515cf34c6579fdf1e3dbfb3907277f..bacee6ef18af8f17a9bf310feb126ca336a18157 100644 (file)
--- a/top.c
+++ b/top.c
@@ -219,7 +219,7 @@ SCB_NUM1(RES, resident)                // also serves MEM !
 SCB_NUM1(SHR, share)
 SCB_NUM1(SID, session)
 SCB_NUMx(STA, state)
-SCB_NUM2(SWP, size, resident)
+SCB_NUM1(SWP, vm_swap)
 SCB_NUMx(THD, nlwp)
                                        // also serves TM2 !
 static int SCB_NAME(TME) (const proc_t **P, const proc_t **Q) {
@@ -1213,7 +1213,7 @@ static FLD_t Fieldstab[] = {
    { "   TIME+  ",  "%9.9s ",     9,     -1,  SF(TME),  L_stat,    "CPU Time, hundredths" },
    { "%MEM ",       "%#4.1f ",   -1,     -1,  SF(RES),  L_statm,   "Memory Usage (RES)"   },
    { " VIRT ",      "%5.5s ",     5,  SK_Kb,  SF(VRT),  L_statm,   "Virtual Image (kb)"   },
-   { "SWAP ",       "%4.4s ",     4,  SK_Kb,  SF(SWP),  L_statm,   "Swapped Size (kb)"    },
+   { "SWAP ",       "%4.4s ",     4,  SK_Kb,  SF(SWP),  L_status,  "Swapped Size (kb)"    },
    { " RES ",       "%4.4s ",     4,  SK_Kb,  SF(RES),  L_statm,   "Resident Size (kb)"   },
    { "CODE ",       "%4.4s ",     4,  SK_Kb,  SF(COD),  L_statm,   "Code Size (kb)"       },
    { "DATA ",       "%4.4s ",     4,  SK_Kb,  SF(DAT),  L_statm,   "Data+Stack Size (kb)" },
@@ -3298,7 +3298,7 @@ static void task_show (const WIN_t *q, const proc_t *p) {
             makeCOL(p->state);
             break;
          case P_SWP:
-            makeCOL(scale_num(pages2K(p->size - p->resident), w, s));
+            makeCOL(scale_num(p->vm_swap, w, s));
             break;
          case P_THD:
             makeCOL(p->nlwp);
diff --git a/top.h b/top.h
index 308b863fbe1be0847551c6db36a8f9247dda1fdf..2a3aa4d5db0507898ad877bd04c83fbed0ed8641 100644 (file)
--- a/top.h
+++ b/top.h
@@ -362,11 +362,6 @@ typedef struct WIN_t {
       if ( (*P)->n < (*Q)->n ) return SORT_lt; \
       if ( (*P)->n > (*Q)->n ) return SORT_gt; \
       return SORT_eq; }
-#define SCB_NUM2(f,n1,n2) \
-   static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
-      if ( ((*P)->n1 - (*P)->n2) < ((*Q)->n1 - (*Q)->n2) ) return SORT_lt; \
-      if ( ((*P)->n1 - (*P)->n2) > ((*Q)->n1 - (*Q)->n2) ) return SORT_gt; \
-      return SORT_eq; }
 #define SCB_NUMx(f,n) \
    static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
       return Frame_srtflg * ( (*Q)->n - (*P)->n ); }