diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-07 03:59:52 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-07 03:59:52 +0100 |
commit | 86107d6dc7b6a182e01fb8296cb4e1680963184d (patch) | |
tree | e9594bb909f54ad1e8282b44390c5ece917c09d2 | |
parent | e1b1b7926975c3cd4313be0019212b1cf68fa529 (diff) | |
download | busybox-w32-86107d6dc7b6a182e01fb8296cb4e1680963184d.tar.gz busybox-w32-86107d6dc7b6a182e01fb8296cb4e1680963184d.tar.bz2 busybox-w32-86107d6dc7b6a182e01fb8296cb4e1680963184d.zip |
top: handle much larger VSZ values
function old new delta
display_process_list 1018 999 -19
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/top.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/procps/top.c b/procps/top.c index b777c494e..9bb3eed29 100644 --- a/procps/top.c +++ b/procps/top.c | |||
@@ -607,7 +607,6 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
607 | }; | 607 | }; |
608 | 608 | ||
609 | top_status_t *s; | 609 | top_status_t *s; |
610 | char vsz_str_buf[8]; | ||
611 | unsigned long total_memory = display_header(scr_width, &lines_rem); /* or use total_vsz? */ | 610 | unsigned long total_memory = display_header(scr_width, &lines_rem); /* or use total_vsz? */ |
612 | /* xxx_shift and xxx_scale variables allow us to replace | 611 | /* xxx_shift and xxx_scale variables allow us to replace |
613 | * expensive divides with multiply and shift */ | 612 | * expensive divides with multiply and shift */ |
@@ -688,19 +687,18 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
688 | lines_rem = ntop - G_scroll_ofs; | 687 | lines_rem = ntop - G_scroll_ofs; |
689 | s = top + G_scroll_ofs; | 688 | s = top + G_scroll_ofs; |
690 | while (--lines_rem >= 0) { | 689 | while (--lines_rem >= 0) { |
690 | char vsz_str_buf[8]; | ||
691 | unsigned col; | 691 | unsigned col; |
692 | |||
692 | CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift); | 693 | CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift); |
693 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE | 694 | #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE |
694 | CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift); | 695 | CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift); |
695 | #endif | 696 | #endif |
696 | 697 | ||
697 | if (s->vsz >= 100000) | 698 | smart_ulltoa5(s->vsz, vsz_str_buf, " mgtpezy"); |
698 | sprintf(vsz_str_buf, "%6ldm", s->vsz/1024); | ||
699 | else | ||
700 | sprintf(vsz_str_buf, "%7lu", s->vsz); | ||
701 | /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ | 699 | /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */ |
702 | col = snprintf(line_buf, scr_width, | 700 | col = snprintf(line_buf, scr_width, |
703 | "\n" "%5u%6u %-8.8s %s%s" FMT | 701 | "\n" "%5u%6u %-8.8s %s %.5s" FMT |
704 | IF_FEATURE_TOP_SMP_PROCESS(" %3d") | 702 | IF_FEATURE_TOP_SMP_PROCESS(" %3d") |
705 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(FMT) | 703 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(FMT) |
706 | " ", | 704 | " ", |
@@ -710,7 +708,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width) | |||
710 | IF_FEATURE_TOP_SMP_PROCESS(, s->last_seen_on_cpu) | 708 | IF_FEATURE_TOP_SMP_PROCESS(, s->last_seen_on_cpu) |
711 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(, SHOW_STAT(pcpu)) | 709 | IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(, SHOW_STAT(pcpu)) |
712 | ); | 710 | ); |
713 | if ((int)(col + 1) < scr_width) | 711 | if ((int)(scr_width - col) > 1) |
714 | read_cmdline(line_buf + col, scr_width - col, s->pid, s->comm); | 712 | read_cmdline(line_buf + col, scr_width - col, s->pid, s->comm); |
715 | fputs(line_buf, stdout); | 713 | fputs(line_buf, stdout); |
716 | /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu, | 714 | /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu, |