1 Change top to display RSS instead of VSZ.
2 By Alexander Shishkin <ext-alexander.shishkin@nokia.com>
4 Ported to BusyBox 1.19 by Dennis Groenen <tj.groenen@gmail.com> - 2011-08-19
12 typedef struct top_status_t {
15 #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
17 unsigned pcpu; /* delta of ticks */
18 @@ -166,8 +166,8 @@ static int pid_sort(top_status_t *P, top
19 static int mem_sort(top_status_t *P, top_status_t *Q)
21 /* We want to avoid unsigned->signed and truncation errors */
22 - if (Q->vsz < P->vsz) return -1;
23 - return Q->vsz != P->vsz; /* 0 if ==, 1 if > */
24 + if (Q->rss < P->rss) return -1;
25 + return Q->rss != P->rss; /* 0 if ==, 1 if > */
29 @@ -538,7 +538,7 @@ static NOINLINE void display_process_lis
31 /* what info of the processes is shown */
32 printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width,
33 - " PID PPID USER STAT VSZ %VSZ"
34 + " PID PPID USER STAT RSS %MEM"
35 IF_FEATURE_TOP_SMP_PROCESS(" CPU")
36 IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU")
38 @@ -556,7 +556,7 @@ static NOINLINE void display_process_lis
42 - * %VSZ = s->vsz/MemTotal
43 + * %MEM = s->vsz/MemTotal
45 pmem_shift = BITS_PER_INT-11;
46 pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory;
47 @@ -607,16 +607,16 @@ static NOINLINE void display_process_lis
49 while (--lines_rem >= 0) {
51 - CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift);
52 + CALC_STAT(pmem, (s->rss*pmem_scale + pmem_half) >> pmem_shift);
53 #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
54 CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift);
57 - if (s->vsz >= 100000)
58 - sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
59 + if (s->rss >= 100000)
60 + sprintf(vsz_str_buf, "%6ldm", s->rss/1024);
62 - sprintf(vsz_str_buf, "%7ld", s->vsz);
63 - /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
64 + sprintf(vsz_str_buf, "%7ld", s->rss);
65 + /* PID PPID USER STAT RSS %MEM %CPU COMMAND */
66 col = snprintf(line_buf, scr_width,
67 "\n" "%5u%6u %-8.8s %s%s" FMT
68 IF_FEATURE_TOP_SMP_PROCESS(" %3d")
69 @@ -1109,7 +1109,7 @@ int top_main(int argc UNUSED_PARAM, char
70 top = xrealloc_vector(top, 6, ntop++);
72 top[n].ppid = p->ppid;
73 - top[n].vsz = p->vsz;
74 + top[n].rss = p->rss;
75 #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
76 top[n].ticks = p->stime + p->utime;