• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/busybox


Commit MetaInfo

Revisionad1fb2457b4a060b6c78b2932fdd59c333c645a6 (tree)
Time2020-04-14 08:42:51
AuthorDenys Vlasenko <vda.linux@goog...>
CommiterMauro Rossi

Log Message

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>

Change Summary

Incremental Difference

--- a/procps/top.c
+++ b/procps/top.c
@@ -595,7 +595,6 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
595595 };
596596
597597 top_status_t *s;
598- char vsz_str_buf[8];
599598 unsigned long total_memory = display_header(scr_width, &lines_rem); /* or use total_vsz? */
600599 /* xxx_shift and xxx_scale variables allow us to replace
601600 * expensive divides with multiply and shift */
@@ -676,19 +675,18 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
676675 lines_rem = ntop - G_scroll_ofs;
677676 s = top + G_scroll_ofs;
678677 while (--lines_rem >= 0) {
678+ char vsz_str_buf[8];
679679 unsigned col;
680+
680681 CALC_STAT(pmem, (s->vsz*pmem_scale + pmem_half) >> pmem_shift);
681682 #if ENABLE_FEATURE_TOP_CPU_USAGE_PERCENTAGE
682683 CALC_STAT(pcpu, (s->pcpu*pcpu_scale + pcpu_half) >> pcpu_shift);
683684 #endif
684685
685- if (s->vsz >= 100000)
686- sprintf(vsz_str_buf, "%6ldm", s->vsz/1024);
687- else
688- sprintf(vsz_str_buf, "%7lu", s->vsz);
686+ smart_ulltoa5(s->vsz, vsz_str_buf, " mgtpezy");
689687 /* PID PPID USER STAT VSZ %VSZ [%CPU] COMMAND */
690688 col = snprintf(line_buf, scr_width,
691- "\n" "%5u%6u %-8.8s %s%s" FMT
689+ "\n" "%5u%6u %-8.8s %s %.5s" FMT
692690 IF_FEATURE_TOP_SMP_PROCESS(" %3d")
693691 IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(FMT)
694692 " ",
@@ -698,7 +696,7 @@ static NOINLINE void display_process_list(int lines_rem, int scr_width)
698696 IF_FEATURE_TOP_SMP_PROCESS(, s->last_seen_on_cpu)
699697 IF_FEATURE_TOP_CPU_USAGE_PERCENTAGE(, SHOW_STAT(pcpu))
700698 );
701- if ((int)(col + 1) < scr_width)
699+ if ((int)(scr_width - col) > 1)
702700 read_cmdline(line_buf + col, scr_width - col, s->pid, s->comm);
703701 fputs(line_buf, stdout);
704702 /* printf(" %d/%d %lld/%lld", s->pcpu, total_pcpu,