top: exploit new kb_main_available, make Jaromir happy
This patch will trade a former pessimistic calculation of free physical memory for a more optimistic one that uses the newly added kb_main_available library export. But in case one might wish to return to the old former method, there's a new #define that was made available. [ the new calculation will affect graphing mode only ] Reference(s): http://www.freelists.org/post/procps/systemd-support-to-library,9 Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
9500dc198c
commit
d310a18fc2
18
top/top.1
18
top/top.1
@ -470,14 +470,21 @@ with the `E' \*(CI.
|
|||||||
|
|
||||||
As a default, Line 1 reflects \*(MP, classified as:
|
As a default, Line 1 reflects \*(MP, classified as:
|
||||||
.nf
|
.nf
|
||||||
total, used, free and buffers
|
total, free, used and buff/cache
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
Line 2 reflects mostly \*(MV, classified as:
|
Line 2 reflects mostly \*(MV, classified as:
|
||||||
.nf
|
.nf
|
||||||
total, used, free and cached (which is \*(MP)
|
total, free, used and avail (which is \*(MP)
|
||||||
.fi
|
.fi
|
||||||
|
|
||||||
|
The \fBavail\fR number on line 2 is an estimation of \*(MP available for
|
||||||
|
starting new applications, without swapping.
|
||||||
|
Unlike the \fBfree\fR field, it attempts to account for readily reclaimable
|
||||||
|
page cache and memory slabs.
|
||||||
|
It is available on kernels 3.14, emulated on kernels 2.6.27+ and displayed
|
||||||
|
as zero otherwise.
|
||||||
|
|
||||||
In the alternate memory display modes, two abbreviated summary lines
|
In the alternate memory display modes, two abbreviated summary lines
|
||||||
are shown consisting of these elements:
|
are shown consisting of these elements:
|
||||||
.nf
|
.nf
|
||||||
@ -489,9 +496,10 @@ are shown consisting of these elements:
|
|||||||
Where: a) is the percentage used; b) is the total available; and c) is one of two
|
Where: a) is the percentage used; b) is the total available; and c) is one of two
|
||||||
visual graphs of those representations.
|
visual graphs of those representations.
|
||||||
|
|
||||||
In the case of \*(MP, the percentage includes the sum of \fBused\fR, \fBbuffers\fR
|
In the case of \*(MP, the percentage represents the \fBtotal\fR minus the estimated
|
||||||
and \fBcached\fR memory noted above.
|
\fBavail\fR noted above.
|
||||||
The `Mem' graph itself is divided between \fBused\fR then \fBbuffers\fR and \fBcached\fR combined.
|
The `Mem' graph itself is divided between \fBused\fR the any remaining memory not
|
||||||
|
otherwise accounted for by \fBavail\fR.
|
||||||
\*(XT 4b. SUMMARY AREA Commands and the `m' command for additional information
|
\*(XT 4b. SUMMARY AREA Commands and the `m' command for additional information
|
||||||
on that special 4-way toggle.
|
on that special 4-way toggle.
|
||||||
|
|
||||||
|
15
top/top.c
15
top/top.c
@ -5216,7 +5216,7 @@ numa_nope:
|
|||||||
// and prT macro might replace space at buf[8] with: ------> +
|
// and prT macro might replace space at buf[8] with: ------> +
|
||||||
char buf[10]; // MEMORY_lines_fmt provides for 8+1 bytes
|
char buf[10]; // MEMORY_lines_fmt provides for 8+1 bytes
|
||||||
} buftab[8];
|
} buftab[8];
|
||||||
unsigned long kb_main_my_used;
|
unsigned long kb_main_my_used, kb_main_my_misc;
|
||||||
|
|
||||||
if (!scaletab[0].label) {
|
if (!scaletab[0].label) {
|
||||||
scaletab[0].label = N_txt(AMT_kilobyte_txt);
|
scaletab[0].label = N_txt(AMT_kilobyte_txt);
|
||||||
@ -5226,7 +5226,8 @@ numa_nope:
|
|||||||
scaletab[4].label = N_txt(AMT_petabyte_txt);
|
scaletab[4].label = N_txt(AMT_petabyte_txt);
|
||||||
scaletab[5].label = N_txt(AMT_exxabyte_txt);
|
scaletab[5].label = N_txt(AMT_exxabyte_txt);
|
||||||
}
|
}
|
||||||
kb_main_my_used = kb_main_used - kb_main_buffers - kb_main_cached;
|
kb_main_my_misc = kb_main_buffers + kb_main_cached;
|
||||||
|
kb_main_my_used = kb_main_used - kb_main_my_misc;
|
||||||
|
|
||||||
if (w->rc.graph_mems) {
|
if (w->rc.graph_mems) {
|
||||||
static struct {
|
static struct {
|
||||||
@ -5238,7 +5239,11 @@ numa_nope:
|
|||||||
char used[SMLBUFSIZ], util[SMLBUFSIZ], dual[MEDBUFSIZ];
|
char used[SMLBUFSIZ], util[SMLBUFSIZ], dual[MEDBUFSIZ];
|
||||||
int ix = w->rc.graph_mems - 1;
|
int ix = w->rc.graph_mems - 1;
|
||||||
float pct_used = (float)kb_main_my_used * (100.0 / (float)kb_main_total),
|
float pct_used = (float)kb_main_my_used * (100.0 / (float)kb_main_total),
|
||||||
pct_misc = (float)(kb_main_buffers + kb_main_cached) * (100.0 / (float)kb_main_total),
|
#ifdef MEMGRAPH_OLD
|
||||||
|
pct_misc = (float)kb_main_my_misc * (100.0 / (float)kb_main_total),
|
||||||
|
#else
|
||||||
|
pct_misc = (float)(kb_main_total - kb_main_available - kb_main_my_used) * (100.0 / (float)kb_main_total),
|
||||||
|
#endif
|
||||||
pct_swap = kb_swap_total ? (float)kb_swap_used * (100.0 / (float)kb_swap_total) : 0;
|
pct_swap = kb_swap_total ? (float)kb_swap_used * (100.0 / (float)kb_swap_total) : 0;
|
||||||
snprintf(used, sizeof(used), gtab[ix].used, (int)((pct_used * Graph_adj) + .5), gtab[ix].type);
|
snprintf(used, sizeof(used), gtab[ix].used, (int)((pct_used * Graph_adj) + .5), gtab[ix].type);
|
||||||
snprintf(util, sizeof(util), gtab[ix].misc, (int)((pct_misc * Graph_adj) + .5), gtab[ix].type);
|
snprintf(util, sizeof(util), gtab[ix].misc, (int)((pct_misc * Graph_adj) + .5), gtab[ix].type);
|
||||||
@ -5250,9 +5255,9 @@ numa_nope:
|
|||||||
, scT(label), N_txt(WORD_abv_swp_txt), pct_swap, bfT(1), Graph_len +2, Graph_len +2, util));
|
, scT(label), N_txt(WORD_abv_swp_txt), pct_swap, bfT(1), Graph_len +2, Graph_len +2, util));
|
||||||
} else {
|
} else {
|
||||||
prT(bfT(0), mkM(total)); prT(bfT(1), mkM(free));
|
prT(bfT(0), mkM(total)); prT(bfT(1), mkM(free));
|
||||||
prT(bfT(2), mkM(my_used)); prT(bfT(3), mkM(buffers));
|
prT(bfT(2), mkM(my_used)); prT(bfT(3), mkM(my_misc));
|
||||||
prT(bfT(4), mkS(total)); prT(bfT(5), mkS(free));
|
prT(bfT(4), mkS(total)); prT(bfT(5), mkS(free));
|
||||||
prT(bfT(6), mkS(used)); prT(bfT(7), mkM(cached));
|
prT(bfT(6), mkS(used)); prT(bfT(7), mkM(available));
|
||||||
show_special(0, fmtmk(N_unq(MEMORY_lines_fmt)
|
show_special(0, fmtmk(N_unq(MEMORY_lines_fmt)
|
||||||
, scT(label), N_txt(WORD_abv_mem_txt), bfT(0), bfT(1), bfT(2), bfT(3)
|
, scT(label), N_txt(WORD_abv_mem_txt), bfT(0), bfT(1), bfT(2), bfT(3)
|
||||||
, scT(label), N_txt(WORD_abv_swp_txt), bfT(4), bfT(5), bfT(6), bfT(7)
|
, scT(label), N_txt(WORD_abv_swp_txt), bfT(4), bfT(5), bfT(6), bfT(7)
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
//#define INSP_OFFDEMO /* disable demo screens, issue msg instead */
|
//#define INSP_OFFDEMO /* disable demo screens, issue msg instead */
|
||||||
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
|
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
|
||||||
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
|
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
|
||||||
|
//#define MEMGRAPH_OLD /* don't use 'available' when graphing Mem */
|
||||||
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
|
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
|
||||||
//#define OFF_NUMASKIP /* do NOT skip numa nodes if discontinuous */
|
//#define OFF_NUMASKIP /* do NOT skip numa nodes if discontinuous */
|
||||||
//#define OFF_SCROLLBK /* disable tty emulators scrollback buffer */
|
//#define OFF_SCROLLBK /* disable tty emulators scrollback buffer */
|
||||||
@ -658,6 +659,9 @@ typedef struct WIN_t {
|
|||||||
#if defined(TERMIOS_ONLY)
|
#if defined(TERMIOS_ONLY)
|
||||||
# warning 'TERMIOS_ONLY' disables input recall and makes man doc incorrect
|
# warning 'TERMIOS_ONLY' disables input recall and makes man doc incorrect
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(MEMGRAPH_OLD)
|
||||||
|
# warning 'MEMGRAPH_OLD' will make the man document Section 2c. misleading
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*###### Some Prototypes (ha!) #########################################*/
|
/*###### Some Prototypes (ha!) #########################################*/
|
||||||
|
@ -637,8 +637,8 @@ static void build_uniq_nlstab (void) {
|
|||||||
"%#5.1f ~2us,~3%#5.1f ~2sy,~3%#5.1f ~2ni,~3%#5.1f ~2id,~3%#5.1f ~2wa,~3%#5.1f ~2hi,~3%#5.1f ~2si,~3%#5.1f ~2st~3\n");
|
"%#5.1f ~2us,~3%#5.1f ~2sy,~3%#5.1f ~2ni,~3%#5.1f ~2id,~3%#5.1f ~2wa,~3%#5.1f ~2hi,~3%#5.1f ~2si,~3%#5.1f ~2st~3\n");
|
||||||
|
|
||||||
Uniq_nlstab[MEMORY_lines_fmt] = _(""
|
Uniq_nlstab[MEMORY_lines_fmt] = _(""
|
||||||
"%s %s:~3 %9.9s~2total,~3 %9.9s~2free,~3 %9.9s~2used,~3 %9.9s~2buffers~3\n"
|
"%s %s:~3 %9.9s~2total,~3 %9.9s~2free,~3 %9.9s~2used,~3 %9.9s~2buff/cache~3\n"
|
||||||
"%s %s:~3 %9.9s~2total,~3 %9.9s~2free,~3 %9.9s~2used.~3 %9.9s~2cached %s~3\n");
|
"%s %s:~3 %9.9s~2total,~3 %9.9s~2free,~3 %9.9s~2used.~3 %9.9s~2avail %s~3\n");
|
||||||
|
|
||||||
Uniq_nlstab[INSP_hdrsels_fmt] = _(""
|
Uniq_nlstab[INSP_hdrsels_fmt] = _(""
|
||||||
"Inspection~2 Pause at: pid ~1%d~6 running ~1%s~6 as user ~1%s~6\n"
|
"Inspection~2 Pause at: pid ~1%d~6 running ~1%s~6 as user ~1%s~6\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user