top: replace %MEM with %VSZ in header text

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2011-01-25 12:48:47 +01:00
parent 9b3b9790b3
commit 9aa599dc9d

View File

@ -19,9 +19,9 @@
* *
* Sept 2008: Vineet Gupta <vineet.gupta@arc.com> * Sept 2008: Vineet Gupta <vineet.gupta@arc.com>
* Added Support for reporting SMP Information * Added Support for reporting SMP Information
* - CPU where Process was last seen running * - CPU where process was last seen running
* (to see effect of sched_setaffinity() etc) * (to see effect of sched_setaffinity() etc)
* - CPU Time Split (idle/IO/wait etc) PER CPU * - CPU time split (idle/IO/wait etc) per CPU
* *
* Copyright (c) 1992 Branko Lankester * Copyright (c) 1992 Branko Lankester
* Copyright (c) 1992 Roger Binns * Copyright (c) 1992 Roger Binns
@ -30,14 +30,24 @@
* *
* Licensed under GPLv2, see file LICENSE in this source tree. * Licensed under GPLv2, see file LICENSE in this source tree.
*/ */
/* Howto snapshot /proc for debugging top problems: /* How to snapshot /proc for debugging top problems:
* for f in /proc/[0-9]*""/stat; do * for f in /proc/[0-9]*""/stat; do
* n=${f#/proc/} * n=${f#/proc/}
* n=${n%/stat}_stat * n=${n%/stat}_stat
* cp $f $n * cp $f $n
* done * done
* cp /proc/stat /proc/meminfo . * cp /proc/stat /proc/meminfo /proc/loadavg .
* top -bn1 >top.out * top -bn1 >top.out
*
* ...and how to run top on it on another machine:
* rm -rf proc; mkdir proc
* for f in [0-9]*_stat; do
* p=${f%_stat}
* mkdir -p proc/$p
* cp $f proc/$p/stat
* done
* cp stat meminfo loadavg proc
* chroot . ./top -bn1 >top1.out
*/ */
#include "libbb.h" #include "libbb.h"
@ -528,7 +538,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
/* what info of the processes is shown */ /* what info of the processes is shown */
printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width, printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width,
" PID PPID USER STAT VSZ %MEM" " PID PPID USER STAT VSZ %VSZ"
IF_FEATURE_TOP_SMP_PROCESS(" CPU") IF_FEATURE_TOP_SMP_PROCESS(" CPU")
IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU") IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU")
" COMMAND"); " COMMAND");
@ -546,7 +556,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
# define FMT "%4u%%" # define FMT "%4u%%"
#endif #endif
/* /*
* MEM% = s->vsz/MemTotal * %VSZ = s->vsz/MemTotal
*/ */
pmem_shift = BITS_PER_INT-11; pmem_shift = BITS_PER_INT-11;
pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory; pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory;
@ -606,7 +616,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
else else
sprintf(vsz_str_buf, "%7ld", s->vsz); sprintf(vsz_str_buf, "%7ld", s->vsz);
/* PID PPID USER STAT VSZ %MEM [%CPU] COMMAND */ /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
col = snprintf(line_buf, scr_width, col = snprintf(line_buf, scr_width,
"\n" "%5u%6u %-8.8s %s%s" FMT "\n" "%5u%6u %-8.8s %s%s" FMT
IF_FEATURE_TOP_SMP_PROCESS(" %3d") IF_FEATURE_TOP_SMP_PROCESS(" %3d")