Fixed per-process swap information in top and related cleanup.

Thanks to KOSAKI Motohiro and Jim.

Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=532668
This commit is contained in:
Jan Görig 2011-06-02 12:15:14 +02:00
parent 91edf89810
commit 034612c480
3 changed files with 3 additions and 12 deletions

4
top.1
View File

@ -625,8 +625,6 @@ The\fI saved\fR user name.
28.\fB SWAP \*(Em Swapped Size (kb) \fR 28.\fB SWAP \*(Em Swapped Size (kb) \fR
The non-resident portion of a task's address space. The non-resident portion of a task's address space.
SWAP = VIRT - RES.
.TP 4 .TP 4
29.\fB TIME \*(Em \*(PU Time \fR 29.\fB TIME \*(Em \*(PU Time \fR
Total \*(PU time the task has used since it started. 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 It includes all code, data and shared libraries plus pages that have been
swapped out and pages that have been mapped but not used. swapped out and pages that have been mapped but not used.
VIRT = SWAP + RES.
.TP 4 .TP 4
36.\fB WCHAN \*(Em Sleeping in Function \fR 36.\fB WCHAN \*(Em Sleeping in Function \fR
Depending on the availability of the kernel link map ('System.map'), this Depending on the availability of the kernel link map ('System.map'), this

6
top.c
View File

@ -219,7 +219,7 @@ SCB_NUM1(RES, resident) // also serves MEM !
SCB_NUM1(SHR, share) SCB_NUM1(SHR, share)
SCB_NUM1(SID, session) SCB_NUM1(SID, session)
SCB_NUMx(STA, state) SCB_NUMx(STA, state)
SCB_NUM2(SWP, size, resident) SCB_NUM1(SWP, vm_swap)
SCB_NUMx(THD, nlwp) SCB_NUMx(THD, nlwp)
// also serves TM2 ! // also serves TM2 !
static int SCB_NAME(TME) (const proc_t **P, const proc_t **Q) { 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" }, { " TIME+ ", "%9.9s ", 9, -1, SF(TME), L_stat, "CPU Time, hundredths" },
{ "%MEM ", "%#4.1f ", -1, -1, SF(RES), L_statm, "Memory Usage (RES)" }, { "%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)" }, { " 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)" }, { " 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)" }, { "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)" }, { "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); makeCOL(p->state);
break; break;
case P_SWP: case P_SWP:
makeCOL(scale_num(pages2K(p->size - p->resident), w, s)); makeCOL(scale_num(p->vm_swap, w, s));
break; break;
case P_THD: case P_THD:
makeCOL(p->nlwp); makeCOL(p->nlwp);

5
top.h
View File

@ -362,11 +362,6 @@ typedef struct WIN_t {
if ( (*P)->n < (*Q)->n ) return SORT_lt; \ if ( (*P)->n < (*Q)->n ) return SORT_lt; \
if ( (*P)->n > (*Q)->n ) return SORT_gt; \ if ( (*P)->n > (*Q)->n ) return SORT_gt; \
return SORT_eq; } 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) \ #define SCB_NUMx(f,n) \
static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \ static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
return Frame_srtflg * ( (*Q)->n - (*P)->n ); } return Frame_srtflg * ( (*Q)->n - (*P)->n ); }