upload tizen1.0 source
[external/busybox.git] / util-linux / packaging / top-display-rss.patch
1 diff --git a/procps/top.c b/procps/top.c
2 index ec84374..9049578 100644
3 --- a/procps/top.c
4 +++ b/procps/top.c
5 @@ -35,7 +35,7 @@
6  
7  
8  typedef struct top_status_t {
9 -       unsigned long vsz;
10 +       unsigned long rss;
11  #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
12         unsigned long ticks;
13         unsigned pcpu; /* delta of ticks */
14 @@ -147,8 +147,8 @@ static int pid_sort(top_status_t *P, top_status_t *Q)
15  static int mem_sort(top_status_t *P, top_status_t *Q)
16  {
17         /* We want to avoid unsigned->signed and truncation errors */
18 -       if (Q->vsz < P->vsz) return -1;
19 -       return Q->vsz != P->vsz; /* 0 if ==, 1 if > */
20 +       if (Q->rss < P->rss) return -1;
21 +       return Q->rss != P->rss; /* 0 if ==, 1 if > */
22  }
23  
24  
25 @@ -519,7 +519,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
26  
27         /* what info of the processes is shown */
28         printf(OPT_BATCH_MODE ? "%.*s" : "\033[7m%.*s\033[0m", scr_width,
29 -               "  PID  PPID USER     STAT   VSZ %MEM"
30 +               "  PID  PPID USER     STAT   RSS %MEM"
31                 IF_FEATURE_TOP_SMP_PROCESS(" CPU")
32                 IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(" %CPU")
33                 " COMMAND");
34 @@ -588,16 +588,16 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
35         s = top;
36         while (--lines_rem >= 0) {
37                 unsigned col;
38 -               CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift);
39 +               CALC_STAT(pmem, (s->rss*pmem_scale + pmem_half) >> pmem_shift);
40  #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
41                 CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift);
42  #endif
43  
44 -               if (s->vsz >= 100000)
45 -                       sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
46 +               if (s->rss >= 100000)
47 +                       sprintf(vsz_str_buf, "%6ldm", s->rss/1024);
48                 else
49 -                       sprintf(vsz_str_buf, "%7ld", s->vsz);
50 -               /* PID PPID USER STAT VSZ %MEM [%CPU] COMMAND */
51 +                       sprintf(vsz_str_buf, "%7ld", s->rss);
52 +               /* PID PPID USER STAT VSZ %RSS [%CPU] COMMAND */
53                 col = snprintf(line_buf, scr_width,
54                                 "\n" "%5u%6u %-8.8s %s%s" FMT
55                                 IF_FEATURE_TOP_SMP_PROCESS(" %3d")
56 @@ -929,7 +929,7 @@ int top_main(int argc UNUSED_PARAM, char **argv)
57                                 top = xrealloc_vector(top, 6, ntop++);
58                                 top[n].pid = p->pid;
59                                 top[n].ppid = p->ppid;
60 -                               top[n].vsz = p->vsz;
61 +                               top[n].rss = p->rss;
62  #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
63                                 top[n].ticks = p->stime + p->utime;
64  #endif