From 034612c48032e8b140b98812482b3a4a621c175b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20G=C3=B6rig?= Date: Thu, 2 Jun 2011 12:15:14 +0200 Subject: [PATCH] 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 --- top.1 | 4 ---- top.c | 6 +++--- top.h | 5 ----- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/top.1 b/top.1 index 51e27338..6e9b2d8e 100644 --- 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 b9e5e869..bacee6ef 100644 --- 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 308b863f..2a3aa4d5 100644 --- 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 ); }