1 Change top to display RSS instead of VSZ.
2 Original patch by Alexander Shishkin <ext-alexander.shishkin@nokia.com>
9 typedef struct top_status_t {
12 #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
14 unsigned pcpu; /* delta of ticks */
15 @@ -228,8 +228,8 @@ static int pid_sort(top_status_t *P, top
16 static int mem_sort(top_status_t *P, top_status_t *Q)
18 /* We want to avoid unsigned->signed and truncation errors */
19 - if (Q->vsz < P->vsz) return -1;
20 - return Q->vsz != P->vsz; /* 0 if ==, 1 if > */
21 + if (Q->rss < P->rss) return -1;
22 + return Q->rss != P->rss; /* 0 if ==, 1 if > */
26 @@ -600,7 +600,7 @@ static NOINLINE void display_process_lis
28 /* what info of the processes is shown */
29 printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width,
30 - " PID PPID USER STAT VSZ %VSZ"
31 + " PID PPID USER STAT RSS %MEM"
32 IF_FEATURE_TOP_SMP_PROCESS(" CPU")
33 IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU")
35 @@ -618,7 +618,7 @@ static NOINLINE void display_process_lis
39 - * %VSZ = s->vsz/MemTotal
40 + * %MEM = s->vsz/MemTotal
42 pmem_shift = BITS_PER_INT-11;
43 pmem_scale = UPSCALE*(1U<<(BITS_PER_INT-11)) / total_memory;
44 @@ -669,16 +669,16 @@ static NOINLINE void display_process_lis
45 s = top + G_scroll_ofs;
46 while (--lines_rem >= 0) {
48 - CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift);
49 + CALC_STAT(pmem, (s->rss*pmem_scale + pmem_half) >> pmem_shift);
50 #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
51 CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift);
54 - if (s->vsz >= 100000)
55 - sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
56 + if (s->rss >= 100000)
57 + sprintf(vsz_str_buf, "%6ldm", s->rss/1024);
59 - sprintf(vsz_str_buf, "%7ld", s->vsz);
60 - /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
61 + sprintf(vsz_str_buf, "%7ld", s->rss);
62 + /* PID PPID USER STAT RSS %MEM %CPU COMMAND */
63 col = snprintf(line_buf, scr_width,
64 "\n" "%5u%6u %-8.8s %s%s" FMT
65 IF_FEATURE_TOP_SMP_PROCESS(" %3d")
66 @@ -1212,7 +1212,7 @@ int top_main(int argc UNUSED_PARAM, char
67 top = xrealloc_vector(top, 6, ntop++);
69 top[n].ppid = p->ppid;
70 - top[n].vsz = p->vsz;
71 + top[n].rss = p->rss;
72 #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
73 top[n].ticks = p->stime + p->utime;