top: avoid an unnecessary conversion for 'USED' column

When the USED column was introduced the proc_t.vm_swap
& proc_t.resident values were added together. However,
using 'resident' required an additional PROC_FILL flag
not to mention extra conversion of pages to kibibytes.

So now we'll use an already present vm_rss value which
removes any special handling for top's derived column.

And while we're at it we'll trade some more 'resident'
field uses with that more immediately usable 'vm_rss'.

[ this commit has been adapted for the newlib branch ]

Reference(s):
commit 709785e20b

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2015-08-01 10:52:20 -05:00 committed by Craig Small
parent 479845d4f0
commit b7fe46a815

View File

@ -306,7 +306,7 @@ SCB_NUMx(PGD, pgrp)
SCB_NUMx(PID, tid) SCB_NUMx(PID, tid)
SCB_NUMx(PPD, ppid) SCB_NUMx(PPD, ppid)
SCB_NUMx(PRI, priority) SCB_NUMx(PRI, priority)
SCB_NUM1(RES, resident) // also serves MEM ! SCB_NUM1(RES, vm_rss) // also serves MEM !
SCB_STRX(SGD, supgid) SCB_STRX(SGD, supgid)
SCB_STRS(SGN, supgrp) SCB_STRS(SGN, supgrp)
SCB_NUM1(SHR, share) SCB_NUM1(SHR, share)
@ -339,7 +339,7 @@ SCB_STRS(UEN, euser)
SCB_NUMx(URD, ruid) SCB_NUMx(URD, ruid)
SCB_STRS(URN, ruser) SCB_STRS(URN, ruser)
SCB_NUMx(USD, suid) SCB_NUMx(USD, suid)
SCB_NUM2(USE, resident, vm_swap) SCB_NUM2(USE, vm_rss, vm_swap)
SCB_STRS(USN, suser) SCB_STRS(USN, suser)
SCB_NUM1(VRT, size) SCB_NUM1(VRT, size)
SCB_NUM1(WCH, wchan) SCB_NUM1(WCH, wchan)
@ -1716,7 +1716,6 @@ end_justifies:
#define L_OUSER PROC_FILLSTATUS | PROC_FILLUSR #define L_OUSER PROC_FILLSTATUS | PROC_FILLUSR
#define L_EGROUP PROC_FILLSTATUS | PROC_FILLGRP #define L_EGROUP PROC_FILLSTATUS | PROC_FILLGRP
#define L_SUPGRP PROC_FILLSTATUS | PROC_FILLSUPGRP #define L_SUPGRP PROC_FILLSTATUS | PROC_FILLSUPGRP
#define L_USED PROC_FILLSTATUS | PROC_FILLMEM
#define L_NS PROC_FILLNS #define L_NS PROC_FILLNS
#define L_LXC PROC_FILL_LXC #define L_LXC PROC_FILL_LXC
// make 'none' non-zero (used to be important to Frames_libflags) // make 'none' non-zero (used to be important to Frames_libflags)
@ -1769,21 +1768,21 @@ static FLD_t Fieldstab[] = {
{ 6, -1, A_right, SF(TME), L_stat }, { 6, -1, A_right, SF(TME), L_stat },
{ 9, -1, A_right, SF(TME), L_stat }, // EU_TM2 slot { 9, -1, A_right, SF(TME), L_stat }, // EU_TM2 slot
#ifdef BOOST_PERCNT #ifdef BOOST_PERCNT
{ 5, -1, A_right, SF(RES), L_statm }, // EU_MEM slot { 5, -1, A_right, SF(RES), L_status }, // EU_MEM slot
#else #else
{ 4, -1, A_right, SF(RES), L_statm }, // EU_MEM slot { 4, -1, A_right, SF(RES), L_status }, // EU_MEM slot
#endif #endif
#ifndef NOBOOST_MEMS #ifndef NOBOOST_MEMS
{ 7, SK_Kb, A_right, SF(VRT), L_statm }, { 7, SK_Kb, A_right, SF(VRT), L_statm },
{ 6, SK_Kb, A_right, SF(SWP), L_status }, { 6, SK_Kb, A_right, SF(SWP), L_status },
{ 6, SK_Kb, A_right, SF(RES), L_statm }, { 6, SK_Kb, A_right, SF(RES), L_status },
{ 6, SK_Kb, A_right, SF(COD), L_statm }, { 6, SK_Kb, A_right, SF(COD), L_statm },
{ 7, SK_Kb, A_right, SF(DAT), L_statm }, { 7, SK_Kb, A_right, SF(DAT), L_statm },
{ 6, SK_Kb, A_right, SF(SHR), L_statm }, { 6, SK_Kb, A_right, SF(SHR), L_statm },
#else #else
{ 5, SK_Kb, A_right, SF(VRT), L_statm }, { 5, SK_Kb, A_right, SF(VRT), L_statm },
{ 4, SK_Kb, A_right, SF(SWP), L_status }, { 4, SK_Kb, A_right, SF(SWP), L_status },
{ 4, SK_Kb, A_right, SF(RES), L_statm }, { 4, SK_Kb, A_right, SF(RES), L_status },
{ 4, SK_Kb, A_right, SF(COD), L_statm }, { 4, SK_Kb, A_right, SF(COD), L_statm },
{ 5, SK_Kb, A_right, SF(DAT), L_statm }, { 5, SK_Kb, A_right, SF(DAT), L_statm },
{ 4, SK_Kb, A_right, SF(SHR), L_statm }, { 4, SK_Kb, A_right, SF(SHR), L_statm },
@ -1809,9 +1808,9 @@ static FLD_t Fieldstab[] = {
{ 3, -1, A_right, SF(FV1), L_stat }, { 3, -1, A_right, SF(FV1), L_stat },
{ 3, -1, A_right, SF(FV2), L_stat }, { 3, -1, A_right, SF(FV2), L_stat },
#ifndef NOBOOST_MEMS #ifndef NOBOOST_MEMS
{ 6, SK_Kb, A_right, SF(USE), L_USED }, { 6, SK_Kb, A_right, SF(USE), L_status },
#else #else
{ 4, SK_Kb, A_right, SF(USE), L_USED }, { 4, SK_Kb, A_right, SF(USE), L_status },
#endif #endif
{ 10, -1, A_right, SF(NS1), L_NS }, // IPCNS { 10, -1, A_right, SF(NS1), L_NS }, // IPCNS
{ 10, -1, A_right, SF(NS2), L_NS }, // MNTNS { 10, -1, A_right, SF(NS2), L_NS }, // MNTNS
@ -5362,7 +5361,7 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
cp = make_str(p->lxcname, W, Js, EU_LXC); cp = make_str(p->lxcname, W, Js, EU_LXC);
break; break;
case EU_MEM: case EU_MEM:
cp = scale_pcnt((float)pages2K(p->resident) * 100 / MEM_VAL(mem_TOTAL), W, Jn); cp = scale_pcnt((float)p->vm_rss * 100 / MEM_VAL(mem_TOTAL), W, Jn);
break; break;
case EU_NCE: case EU_NCE:
cp = make_num(p->nice, W, Jn, AUTOX_NO); cp = make_num(p->nice, W, Jn, AUTOX_NO);
@ -5402,7 +5401,7 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
cp = make_num(p->priority, W, Jn, AUTOX_NO); cp = make_num(p->priority, W, Jn, AUTOX_NO);
break; break;
case EU_RES: case EU_RES:
cp = scale_mem(S, pages2K(p->resident), W, Jn); cp = scale_mem(S, p->vm_rss, W, Jn);
break; break;
case EU_SGD: case EU_SGD:
makeVAR(p->supgid); makeVAR(p->supgid);
@ -5460,7 +5459,7 @@ static const char *task_show (const WIN_t *q, const proc_t *p) {
cp = make_num(p->suid, W, Jn, EU_USD); cp = make_num(p->suid, W, Jn, EU_USD);
break; break;
case EU_USE: case EU_USE:
cp = scale_mem(S, (p->vm_swap + pages2K(p->resident)), W, Jn); cp = scale_mem(S, (p->vm_swap + p->vm_rss), W, Jn);
break; break;
case EU_USN: case EU_USN:
cp = make_str(p->suser, W, Js, EU_USN); cp = make_str(p->suser, W, Js, EU_USN);