From e6cb40235eaba633bdea6b2b98b9c366f3c1ab9e Mon Sep 17 00:00:00 2001 From: Jim Warner Date: Tue, 18 Dec 2012 00:00:00 -0600 Subject: [PATCH] top: extend scaled summary memory range to include EiB This commit increases the upper limit for summary area memory scaling to 9999.999 Exbibytes. It also enhances the man page through a helpful table for equivalences. (now that we know a '.' + 2 spaces is squeezed to one) (everything's perfectly justified, but it's just luck) Reference(s): http://www.freelists.org/post/procps/top-regression-reports http://www.freelists.org/post/procps/top-enhancements-i-hope,1 Signed-off-by: Jim Warner --- top/top.1 | 24 +++++++++++++++++++----- top/top.c | 26 +++++++++++++++----------- top/top.h | 2 +- top/top_nls.c | 6 ++++++ top/top_nls.h | 37 +++++++++++++++++++------------------ 5 files changed, 60 insertions(+), 35 deletions(-) diff --git a/top/top.1 b/top/top.1 index fb9d740c..1156cef6 100644 --- a/top/top.1 +++ b/top/top.1 @@ -420,15 +420,29 @@ kernel versions are shown first. .\" ...................................................................... .SS 2c. MEMORY Usage .\" ---------------------------------------------------------------------- -This portion consists of two lines which may express values in kibibytes (KiB), -mebibytes (MiB) or gibibytes (GiB) depending on the scaling factor enforced +This portion consists of two lines which may express values in kibibytes (KiB) +through exbibytes (EiB) depending on the scaling factor enforced with the 'E' \*(CI. Line 1 reflects \*(MP, classified as: +.Bd -literal -compact total, used, free and buffers +.Ed Line 2 reflects mostly \*(MV, classified as: +.Bd -literal -compact total, used, free and cached (which is \*(MP) +.Ed + +This table may help in interpreting the scaled values displayed: +.Bd -literal -compact + KiB = kibibyte = 1024 bytes + MiB = mebibyte = 1024 KiB = 1,048,576 bytes + GiB = gibibyte = 1024 MiB = 1,073,741,824 bytes + TiB = tebibyte = 1024 GiB = 1,099,511,627,776 bytes + PiB = pebibyte = 1024 TiB = 1,125,899,906,842,624 bytes + EiB = exbibyte = 1024 PiB = 1,152,921,504,606,846,976 bytes +.Ed .\" ---------------------------------------------------------------------- .SH 3. FIELDS / Columns @@ -947,12 +961,12 @@ help and view the system summary on the second line. .TP 7 \ \ \'\fBE\fR\' :\fIExtend-Memory-Scale\fR in Summary Area With this command you can cycle through the available \*(SA memory scaling -which ranges from KiB (kibibytes or 1,024 bytes) through TiB (tebibytes or -1,099,511,627,776 bytes). +which ranges from KiB (kibibytes or 1,024 bytes) through EiB (exbibytes or +1,152,921,504,606,846,976 bytes). If you see a '+' between a displayed number and the following label, it means that \*(We was forced to truncate some portion of that number. -By raising the scaling factor, such truncation can usually be avoided. +By raising the scaling factor, such truncation can be avoided. .TP 7 \ \ \'\fBe\fR\' :\fIExtend-Memory-Scale\fR in Task Windows diff --git a/top/top.c b/top/top.c index 1786ab10..f94af054 100644 --- a/top/top.c +++ b/top/top.c @@ -3834,10 +3834,10 @@ static void keys_global (int ch) { } break; case 'E': - if (++Rc.summ_mscale >= SK_SENTINEL) Rc.summ_mscale = SK_Kb; + if (++Rc.summ_mscale > SK_Eb) Rc.summ_mscale = SK_Kb; break; case 'e': - if (++Rc.task_mscale >= SK_SENTINEL) Rc.task_mscale = SK_Kb; + if (++Rc.task_mscale > SK_Tb) Rc.task_mscale = SK_Kb; break; case 'F': case 'f': @@ -4545,14 +4545,16 @@ static void summary_show (void) { const char *fmts; const char *label; } scaletab[] = { - { 1, "%8.0f ", NULL }, // kilo - { 1024.0, "%#5.2f ", NULL }, // mega - { 1024.0*1024, "%#4.3f ", NULL }, // giga - { 1024.0*1024*1024, "%#3.4f ", NULL } // tera + { 1, "%8.0f ", NULL }, // kibibytes + { 1024.0, "%#4.3f ", NULL }, // mebibytes + { 1024.0*1024, "%#4.3f ", NULL }, // gibibytes + { 1024.0*1024*1024, "%#4.3f ", NULL }, // tebibytes + { 1024.0*1024*1024*1024, "%#4.3f ", NULL }, // pebibytes + { 1024.0*1024*1024*1024*1024, "%#4.3f ", NULL } // exbibytes }; - struct { - // after snprintf, contents of each buf: 'nnnnnnnn 0' - // and prT macro might replace space at buf[8] with: ---> + + struct { // 0123456789 + // snprintf contents of each buf (after SK_Kb): 'nnnn.nnn 0' + // and prT macro might replace space at buf[8] with: ------> + char buf[10]; // MEMORY_lines_fmt provides for 8+1 bytes } buftab[8]; @@ -4561,6 +4563,8 @@ static void summary_show (void) { scaletab[1].label = N_txt(AMT_megabyte_txt); scaletab[2].label = N_txt(AMT_gigabyte_txt); scaletab[3].label = N_txt(AMT_terabyte_txt); + scaletab[4].label = N_txt(AMT_petabyte_txt); + scaletab[5].label = N_txt(AMT_exxabyte_txt); } prT(bfT(0), mkM(total)); prT(bfT(1), mkM(used)); prT(bfT(2), mkM(free)); prT(bfT(3), mkM(buffers)); @@ -4568,8 +4572,8 @@ static void summary_show (void) { prT(bfT(6), mkS(free)); prT(bfT(7), mkM(cached)); show_special(0, fmtmk(N_unq(MEMORY_lines_fmt) - , scT(label), &bfT(0), &bfT(1), &bfT(2), &bfT(3) - , scT(label), &bfT(4), &bfT(5), &bfT(6), &bfT(7))); + , scT(label), bfT(0), bfT(1), bfT(2), bfT(3) + , scT(label), bfT(4), bfT(5), bfT(6), bfT(7))); Msg_row += 2; #undef bfT #undef scT diff --git a/top/top.h b/top/top.h index 4eb58ad4..7ee38e8f 100644 --- a/top/top.h +++ b/top/top.h @@ -194,7 +194,7 @@ enum pflag { /* The scaling 'target' used with memory fields */ enum scale_enum { - SK_Kb, SK_Mb, SK_Gb, SK_Tb, SK_SENTINEL + SK_Kb, SK_Mb, SK_Gb, SK_Tb, SK_Pb, SK_Eb, SK_SENTINEL }; /* This typedef just ensures consistent 'process flags' handling */ diff --git a/top/top_nls.c b/top/top_nls.c index 66dfeeb2..18b76516 100644 --- a/top/top_nls.c +++ b/top/top_nls.c @@ -356,6 +356,12 @@ static void build_norm_nlstab (void) { /* Translation Hint: This is an abbreviation (limit 3 characters) for: . tebibytes (1,099,511,627,776 bytes) */ Norm_nlstab[AMT_terabyte_txt] = _("TiB"); +/* Translation Hint: This is an abbreviation (limit 3 characters) for: + . pebibytes (1,024 tebibytes) */ + Norm_nlstab[AMT_petabyte_txt] = _("PiB"); +/* Translation Hint: This is an abbreviation (limit 3 characters) for: + . exbibytes (1,024 pebibytes) */ + Norm_nlstab[AMT_exxabyte_txt] = _("EiB"); Norm_nlstab[WORD_threads_txt] = _("Threads"); Norm_nlstab[WORD_process_txt] = _("Tasks"); /* Translation Hint: The following "word" is meant to represent either a single diff --git a/top/top_nls.h b/top/top_nls.h index e1488b42..52a1e2c3 100644 --- a/top/top_nls.h +++ b/top/top_nls.h @@ -63,24 +63,25 @@ extern const char *Uniq_nlstab[]; */ enum norm_nls { AMT_kilobyte_txt, AMT_megabyte_txt, AMT_gigabyte_txt, AMT_terabyte_txt, - BAD_delayint_fmt, BAD_integers_txt, BAD_max_task_txt, BAD_mon_pids_fmt, - BAD_niterate_fmt, BAD_numfloat_txt, BAD_signalid_txt, BAD_username_txt, - BAD_widtharg_fmt, CHOOSE_group_txt, COLORS_nomap_txt, DELAY_badarg_txt, - DELAY_change_fmt, DELAY_secure_txt, DISABLED_cmd_txt, DISABLED_win_fmt, - EXIT_signals_fmt, FAIL_alloc_c_txt, FAIL_alloc_r_txt, FAIL_openlib_fmt, - FAIL_rc_open_fmt, FAIL_re_nice_fmt, FAIL_sigmask_fmt, FAIL_signals_fmt, - FAIL_sigstop_fmt, FAIL_statget_txt, FAIL_statopn_fmt, FAIL_tty_get_txt, - FAIL_tty_mod_fmt, FAIL_tty_raw_fmt, FAIL_widecpu_txt, FAIL_widepid_txt, - FIND_no_find_fmt, FIND_no_next_txt, FOREST_modes_fmt, FOREST_views_txt, - GET_find_str_txt, GET_max_task_fmt, GET_nice_num_fmt, GET_pid2kill_fmt, - GET_pid2nice_fmt, GET_sigs_num_fmt, GET_user_ids_txt, HELP_cmdline_fmt, - HILIGHT_cant_txt, IRIX_curmode_fmt, LIMIT_exceed_fmt, MISSING_args_fmt, - NAME_windows_fmt, NOT_onsecure_txt, NOT_smp_cpus_txt, OFF_one_word_txt, - ON_word_only_txt, RC_bad_entry_fmt, RC_bad_files_fmt, SCROLL_coord_fmt, - SELECT_clash_txt, THREADS_show_fmt, TIME_accumed_fmt, UNKNOWN_cmds_txt, - UNKNOWN_opts_fmt, USAGE_abbrev_txt, WORD_allcpus_txt, WORD_another_txt, - WORD_eachcpu_fmt, WORD_process_txt, WORD_threads_txt, WRITE_rcfile_fmt, - WRONG_switch_fmt, XTRA_fixwide_fmt, XTRA_sortopt_fmt, XTRA_warncfg_txt, + AMT_petabyte_txt, AMT_exxabyte_txt, BAD_delayint_fmt, BAD_integers_txt, + BAD_max_task_txt, BAD_mon_pids_fmt, BAD_niterate_fmt, BAD_numfloat_txt, + BAD_signalid_txt, BAD_username_txt, BAD_widtharg_fmt, CHOOSE_group_txt, + COLORS_nomap_txt, DELAY_badarg_txt, DELAY_change_fmt, DELAY_secure_txt, + DISABLED_cmd_txt, DISABLED_win_fmt, EXIT_signals_fmt, FAIL_alloc_c_txt, + FAIL_alloc_r_txt, FAIL_openlib_fmt, FAIL_rc_open_fmt, FAIL_re_nice_fmt, + FAIL_sigmask_fmt, FAIL_signals_fmt, FAIL_sigstop_fmt, FAIL_statget_txt, + FAIL_statopn_fmt, FAIL_tty_get_txt, FAIL_tty_mod_fmt, FAIL_tty_raw_fmt, + FAIL_widecpu_txt, FAIL_widepid_txt, FIND_no_find_fmt, FIND_no_next_txt, + FOREST_modes_fmt, FOREST_views_txt, GET_find_str_txt, GET_max_task_fmt, + GET_nice_num_fmt, GET_pid2kill_fmt, GET_pid2nice_fmt, GET_sigs_num_fmt, + GET_user_ids_txt, HELP_cmdline_fmt, HILIGHT_cant_txt, IRIX_curmode_fmt, + LIMIT_exceed_fmt, MISSING_args_fmt, NAME_windows_fmt, NOT_onsecure_txt, + NOT_smp_cpus_txt, OFF_one_word_txt, ON_word_only_txt, RC_bad_entry_fmt, + RC_bad_files_fmt, SCROLL_coord_fmt, SELECT_clash_txt, THREADS_show_fmt, + TIME_accumed_fmt, UNKNOWN_cmds_txt, UNKNOWN_opts_fmt, USAGE_abbrev_txt, + WORD_allcpus_txt, WORD_another_txt, WORD_eachcpu_fmt, WORD_process_txt, + WORD_threads_txt, WRITE_rcfile_fmt, WRONG_switch_fmt, XTRA_fixwide_fmt, + XTRA_sortopt_fmt, XTRA_warncfg_txt, #ifndef INSP_OFFDEMO YINSP_demo01_txt, YINSP_demo02_txt, YINSP_demo03_txt, YINSP_deqfmt_txt, YINSP_deqtyp_txt, YINSP_dstory_txt,