diff options
author | Mike Frysinger | 2007-02-08 08:21:58 +0000 |
---|---|---|
committer | Mike Frysinger | 2007-02-08 08:21:58 +0000 |
commit | 0aa6ba5d44af32d0bf460c8d92cda686bae64c92 (patch) | |
tree | 72424e60f565c397b8a2b10f88855f11b46c4010 /procps | |
parent | 4423e5beefd6f17dfa836211899ee70edcc64a5b (diff) | |
download | busybox-0aa6ba5d44af32d0bf460c8d92cda686bae64c92.zip busybox-0aa6ba5d44af32d0bf460c8d92cda686bae64c92.tar.gz |
make sure ps/top output what they claim: vsz, not rss ... down the line we should make the output controllable either at runtime or buildtime as both statistics are quite useful
Diffstat (limited to 'procps')
-rw-r--r-- | procps/ps.c | 16 | ||||
-rw-r--r-- | procps/top.c | 42 |
2 files changed, 29 insertions, 29 deletions
diff --git a/procps/ps.c b/procps/ps.c index f3d11b7..a9da807 100644 --- a/procps/ps.c +++ b/procps/ps.c @@ -47,10 +47,10 @@ static void func_pgid(char *buf, int size, const procps_status_t *ps) snprintf(buf, size+1, "%*u", size, ps->pgid); } -static void func_rss(char *buf, int size, const procps_status_t *ps) +static void func_vsz(char *buf, int size, const procps_status_t *ps) { char buf5[5]; - smart_ulltoa5( ((unsigned long long)ps->rss) << 10, buf5); + smart_ulltoa5( ((unsigned long long)ps->vsz) << 10, buf5); snprintf(buf, size+1, "%.*s", size, buf5); } @@ -103,9 +103,9 @@ static const ps_out_t out_spec[] = { // { "ruser" ,"RUSER" ,func_ruser ,PSSCAN_UIDGID,sizeof("RUSER" )-1 }, // { "time" ,"TIME" ,func_time ,PSSCAN_ ,sizeof("TIME" )-1 }, // { "tty" ,"TT" ,func_tty ,PSSCAN_ ,sizeof("TT" )-1 }, -// { "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ ,4 }, + { "vsz" ,"VSZ" ,func_vsz ,PSSCAN_VSZ ,4 }, // Not mandated by POSIX: - { "rss" ,"RSS" ,func_rss ,PSSCAN_RSS ,4 }, +// { "rss" ,"RSS" ,func_rss ,PSSCAN_RSS ,4 }, }; #define VEC_SIZE(v) ( sizeof(v) / sizeof((v)[0]) ) @@ -321,13 +321,13 @@ int ps_main(int argc, char **argv) if (use_selinux) puts(" PID Context Stat Command"); else - puts(" PID Uid VmSize Stat Command"); + puts(" PID Uid VSZ Stat Command"); while ((p = procps_scan(p, 0 | PSSCAN_PID | PSSCAN_UIDGID | PSSCAN_STATE - | PSSCAN_RSS + | PSSCAN_VSZ | PSSCAN_CMD ))) { char *namecmd = p->cmd; @@ -355,12 +355,12 @@ int ps_main(int argc, char **argv) #endif { const char *user = get_cached_username(p->uid); - if (p->rss == 0) + if (p->vsz == 0) len = printf("%5u %-8s %s ", p->pid, user, p->state); else len = printf("%5u %-8s %6ld %s ", - p->pid, user, p->rss, p->state); + p->pid, user, p->vsz, p->state); } i = terminal_width-len; diff --git a/procps/top.c b/procps/top.c index 2681f97..ee6ee5d 100644 --- a/procps/top.c +++ b/procps/top.c @@ -32,7 +32,7 @@ typedef struct { - unsigned long rss; + unsigned long vsz; #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE unsigned long ticks; unsigned pcpu; /* delta of ticks */ @@ -55,7 +55,7 @@ static struct save_hist *prev_hist; static int prev_hist_count; /* static int hist_iterations; */ static unsigned total_pcpu; -/* static unsigned long total_rss; */ +/* static unsigned long total_vsz; */ #endif #define OPT_BATCH_MODE (option_mask32 & 0x4) @@ -72,8 +72,8 @@ static int pid_sort(top_status_t *P, top_status_t *Q) static int mem_sort(top_status_t *P, top_status_t *Q) { /* We want to avoid unsigned->signed and truncation errors */ - if (Q->rss < P->rss) return -1; - return Q->rss != P->rss; /* 0 if ==, 1 if > */ + if (Q->vsz < P->vsz) return -1; + return Q->vsz != P->vsz; /* 0 if ==, 1 if > */ } @@ -147,7 +147,7 @@ static void do_stats(void) get_jiffy_counts(); total_pcpu = 0; - /* total_rss = 0; */ + /* total_vsz = 0; */ new_hist = xmalloc(sizeof(struct save_hist)*ntop); /* * Make a pass through the data to get stats. @@ -179,7 +179,7 @@ static void do_stats(void) i = (i+1) % prev_hist_count; /* hist_iterations++; */ } while (i != last_i); - /* total_rss += cur->rss; */ + /* total_vsz += cur->vsz; */ } /* @@ -287,8 +287,8 @@ static void display_status(int count, int scr_width) }; top_status_t *s = top; - char rss_str_buf[8]; - unsigned long total_memory = display_generic(scr_width); /* or use total_rss? */ + char vsz_str_buf[8]; + unsigned long total_memory = display_generic(scr_width); /* or use total_vsz? */ unsigned pmem_shift, pmem_scale; #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE @@ -297,22 +297,22 @@ static void display_status(int count, int scr_width) /* what info of the processes is shown */ printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, - " PID USER STATUS RSS PPID %CPU %MEM COMMAND"); + " PID USER STATUS VSZ PPID %CPU %MEM COMMAND"); #define MIN_WIDTH \ - sizeof( " PID USER STATUS RSS PPID %CPU %MEM C") + sizeof( " PID USER STATUS VSZ PPID %CPU %MEM C") #else printf(OPT_BATCH_MODE ? "%.*s" : "\e[7m%.*s\e[0m", scr_width, - " PID USER STATUS RSS PPID %MEM COMMAND"); + " PID USER STATUS VSZ PPID %MEM COMMAND"); #define MIN_WIDTH \ - sizeof( " PID USER STATUS RSS PPID %MEM C") + sizeof( " PID USER STATUS VSZ PPID %MEM C") #endif /* - * MEM% = s->rss/MemTotal + * MEM% = s->vsz/MemTotal */ pmem_shift = bits_per_int-11; pmem_scale = 1000*(1U<<(bits_per_int-11)) / total_memory; - /* s->rss is in kb. we want (s->rss * pmem_scale) to never overflow */ + /* s->vsz is in kb. we want (s->vsz * pmem_scale) to never overflow */ while (pmem_scale >= 512) { pmem_scale /= 4; pmem_shift -= 2; @@ -346,14 +346,14 @@ static void display_status(int count, int scr_width) /* printf(" pmem_scale=%u pcpu_scale=%u ", pmem_scale, pcpu_scale); */ #endif while (count-- > 0) { - div_t pmem = div((s->rss*pmem_scale) >> pmem_shift, 10); + div_t pmem = div((s->vsz*pmem_scale) >> pmem_shift, 10); int col = scr_width+1; USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(div_t pcpu;) - if (s->rss >= 100*1024) - sprintf(rss_str_buf, "%6ldM", s->rss/1024); + if (s->vsz >= 100*1024) + sprintf(vsz_str_buf, "%6ldM", s->vsz/1024); else - sprintf(rss_str_buf, "%7ld", s->rss); + sprintf(vsz_str_buf, "%7ld", s->vsz); USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE( pcpu = div((s->pcpu*pcpu_scale) >> pcpu_shift, 10); ) @@ -362,7 +362,7 @@ static void display_status(int count, int scr_width) USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE("%3u.%c") "%3u.%c ", s->pid, get_cached_username(s->uid), s->state, - rss_str_buf, s->ppid, + vsz_str_buf, s->ppid, USE_FEATURE_TOP_CPU_USAGE_PERCENTAGE(pcpu.quot, '0'+pcpu.rem,) pmem.quot, '0'+pmem.rem); if (col > 0) @@ -474,7 +474,7 @@ int top_main(int argc, char **argv) while ((p = procps_scan(p, 0 | PSSCAN_PID | PSSCAN_PPID - | PSSCAN_RSS + | PSSCAN_VSZ | PSSCAN_STIME | PSSCAN_UTIME | PSSCAN_STATE @@ -486,7 +486,7 @@ int top_main(int argc, char **argv) top = xrealloc(top, (++ntop)*sizeof(top_status_t)); top[n].pid = p->pid; top[n].ppid = p->ppid; - top[n].rss = p->rss; + top[n].vsz = p->vsz; #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE top[n].ticks = p->stime + p->utime; #endif |