diff --git a/contrib/top/display.c b/contrib/top/display.c index e65ae24..7ad8913 100644 --- a/contrib/top/display.c +++ b/contrib/top/display.c @@ -66,17 +66,20 @@ char *screenbuf = NULL; static char **procstate_names; static char **cpustate_names; static char **memory_names; +static char **buf_names; static char **arc_names; static char **swap_names; static int num_procstates; static int num_cpustates; static int num_memory; +static int num_buf; static int num_swap; static int *lprocstates; static int *lcpustates; static int *lmemory; +static int *lbuf; static int *lswap; static int num_cpus; @@ -101,16 +104,18 @@ int x_brkdn = 15; int y_brkdn = 1; int x_mem = 5; int y_mem = 3; +int x_buf = 5; +int y_buf = 4; int x_arc = 5; -int y_arc = 4; +int y_arc = 6; int x_swap = 6; -int y_swap = 4; -int y_message = 5; +int y_swap = 7; +int y_message = 8; int x_header = 0; -int y_header = 6; +int y_header = 9; int x_idlecursor = 0; -int y_idlecursor = 5; -int y_procs = 7; +int y_idlecursor = 8; +int y_procs = 8; int y_cpustates = 2; int Header_lines = 7; @@ -219,6 +224,10 @@ struct statics *statics; num_memory = string_count(memory_names); lmemory = (int *)malloc(num_memory * sizeof(int)); + buf_names = statics->buf_names; + num_buf = string_count(buf_names); + lbuf = malloc(num_buf * sizeof(int)); + arc_names = statics->arc_names; /* calculate starting columns where needed */ @@ -632,6 +641,37 @@ int *stats; } /* + * XXX + */ + +char buf_buffer[MAX_COLS]; + +i_buf(stats) + +int *stats; + +{ + fputs("\nBuf: ", stdout); + lastline++; + + /* format and print the memory summary */ + summary_format(buf_buffer, stats, buf_names); + fputs(buf_buffer, stdout); +} + +u_buf(stats) + +int *stats; + +{ + static char new[MAX_COLS]; + + /* format the new line */ + summary_format(new, stats, buf_names); + line_update(buf_buffer, new, x_buf, y_buf); +} + +/* * *_arc(stats) - print "ARC: " followed by the ARC summary string * * Assumptions: cursor is on "lastline" diff --git a/contrib/top/layout.h b/contrib/top/layout.h index a04fce2..5a56b6e 100644 --- a/contrib/top/layout.h +++ b/contrib/top/layout.h @@ -19,15 +19,17 @@ extern int x_brkdn; /* 15 */ extern int y_brkdn; /* 1 */ extern int x_mem; /* 5 */ extern int y_mem; /* 3 */ +extern int x_buf; /* 5 */ +extern int y_buf; /* 4 */ extern int x_arc; /* 5 */ -extern int y_arc; /* 4 */ +extern int y_arc; /* 5 */ extern int x_swap; /* 6 */ -extern int y_swap; /* 4 */ -extern int y_message; /* 5 */ +extern int y_swap; /* 5 */ +extern int y_message; /* 6 */ extern int x_header; /* 0 */ -extern int y_header; /* 6 */ +extern int y_header; /* 7 */ extern int x_idlecursor; /* 0 */ -extern int y_idlecursor; /* 5 */ -extern int y_procs; /* 7 */ +extern int y_idlecursor; /* 6 */ +extern int y_procs; /* 8 */ extern int y_cpustates; /* 2 */ diff --git a/contrib/top/machine.h b/contrib/top/machine.h index 41da600..a200c3d 100644 --- a/contrib/top/machine.h +++ b/contrib/top/machine.h @@ -16,6 +16,7 @@ struct statics char **procstate_names; char **cpustate_names; char **memory_names; + char **buf_names; char **arc_names; char **swap_names; #ifdef ORDER @@ -43,6 +44,7 @@ struct system_info int *procstates; int *cpustates; int *memory; + int *buf; int *arc; int *swap; struct timeval boottime; diff --git a/contrib/top/top.c b/contrib/top/top.c index ebb06e5..3106286 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -123,6 +123,8 @@ int i_cpustates(); int u_cpustates(); int i_memory(); int u_memory(); +int i_buf(); +int u_buf(); int i_arc(); int u_arc(); int i_swap(); @@ -139,6 +141,7 @@ int (*d_loadave)() = i_loadave; int (*d_procstates)() = i_procstates; int (*d_cpustates)() = i_cpustates; int (*d_memory)() = i_memory; +int (*d_buf)() = i_buf; int (*d_arc)() = i_arc; int (*d_swap)() = i_swap; int (*d_message)() = i_message; @@ -663,6 +666,7 @@ restart: /* display memory stats */ (*d_memory)(system_info.memory); + (*d_buf)(system_info.buf); (*d_arc)(system_info.arc); /* display swap stats */ @@ -729,6 +733,7 @@ restart: d_procstates = u_procstates; d_cpustates = u_cpustates; d_memory = u_memory; + d_buf = u_buf; d_arc = u_arc; d_swap = u_swap; d_message = u_message; @@ -1185,6 +1190,7 @@ reset_display() d_procstates = i_procstates; d_cpustates = i_cpustates; d_memory = i_memory; + d_buf = i_buf; d_arc = i_arc; d_swap = i_swap; d_message = i_message; diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index d30cb02..8b41def 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -174,10 +174,16 @@ char *cpustatenames[] = { /* these are for detailing the memory statistics */ -int memory_stats[8]; +int memory_stats[7]; char *memorynames[] = { "K Active, ", "K Inact, ", "K Laundry, ", "K Stasis, ", "K Wired, ", - "K Buf, ", "K Free", NULL + "K Free", NULL +}; + +int buf_stats[7]; +char *bufnames[] = { + "M Cache, ", "M In Flight, ", "M KVA, ", "M Malloc, ", " Dirty Bufs, ", + " Free Bufs", NULL }; int arc_stats[7]; @@ -275,16 +281,18 @@ update_layout(void) { y_mem = 3; - y_arc = 4; - y_swap = 4 + arc_enabled; - y_idlecursor = 5 + arc_enabled; - y_message = 5 + arc_enabled; - y_header = 6 + arc_enabled; - y_procs = 7 + arc_enabled; - Header_lines = 7 + arc_enabled; + y_buf = 4; + y_arc = 5; + y_swap = 5 + arc_enabled; + y_idlecursor = 6 + arc_enabled; + y_message = 6 + arc_enabled; + y_header = 7 + arc_enabled; + y_procs = 8 + arc_enabled; + Header_lines = 8 + arc_enabled; if (pcpu_stats) { y_mem += ncpus - 1; + y_buf += ncpus - 1; y_arc += ncpus - 1; y_swap += ncpus - 1; y_idlecursor += ncpus - 1; @@ -357,6 +365,7 @@ machine_init(struct statics *statics, char do_unames) statics->procstate_names = procstatenames; statics->cpustate_names = cpustatenames; statics->memory_names = memorynames; + statics->buf_names = bufnames; if (arc_enabled) statics->arc_names = arcnames; else @@ -481,30 +490,39 @@ get_system_info(struct system_info *si) /* sum memory & swap statistics */ { + static long _buf_stats[4]; + static int dbufs, fbufs; static unsigned int swap_delay = 0; static int swapavail = 0; static int swapfree = 0; - static long bufspace = 0; static int nspgsin, nspgsout; - GETSYSCTL("vfs.bufspace", bufspace); GETSYSCTL("vm.stats.vm.v_active_count", memory_stats[0]); GETSYSCTL("vm.stats.vm.v_inactive_count", memory_stats[1]); - GETSYSCTL("vm.stats.vm.v_laundry_count", memory_stats[2]); - GETSYSCTL("vm.stats.vm.v_stasis_count", memory_stats[3]); + //GETSYSCTL("vm.stats.vm.v_laundry_count", memory_stats[2]); + //GETSYSCTL("vm.stats.vm.v_stasis_count", memory_stats[3]); + memory_stats[2] = memory_stats[3] = 0; GETSYSCTL("vm.stats.vm.v_wire_count", memory_stats[4]); - GETSYSCTL("vm.stats.vm.v_free_count", memory_stats[6]); + GETSYSCTL("vm.stats.vm.v_free_count", memory_stats[5]); + GETSYSCTL("vfs.bufspace", _buf_stats[0]); + GETSYSCTL("vfs.runningbufspace", _buf_stats[1]); + GETSYSCTL("vfs.bufkvaspace", _buf_stats[2]); + GETSYSCTL("vfs.bufmallocspace", _buf_stats[3]); + GETSYSCTL("vfs.numdirtybuffers", dbufs); + GETSYSCTL("vfs.numfreebuffers", fbufs); GETSYSCTL("vm.stats.vm.v_swappgsin", nspgsin); GETSYSCTL("vm.stats.vm.v_swappgsout", nspgsout); - /* convert memory stats to Kbytes */ - memory_stats[0] = pagetok(memory_stats[0]); - memory_stats[1] = pagetok(memory_stats[1]); - memory_stats[2] = pagetok(memory_stats[2]); - memory_stats[3] = pagetok(memory_stats[3]); - memory_stats[4] = pagetok(memory_stats[4]); - memory_stats[5] = bufspace / 1024; - memory_stats[6] = pagetok(memory_stats[6]); - memory_stats[7] = -1; + + /* convert memory and buf stats */ + for (i = 0; i < nitems(memory_stats) - 1; i++) + memory_stats[i] = pagetok(memory_stats[i]); + memory_stats[nitems(memory_stats) - 1] = -1; + + for (i = 0; i < nitems(_buf_stats) - 1; i++) + buf_stats[i] = (int)(_buf_stats[i] / 1024 / 1024); + buf_stats[4] = dbufs; + buf_stats[5] = fbufs; + buf_stats[nitems(buf_stats) - 1] = -1; /* first interval */ if (swappgsin < 0) { @@ -558,6 +576,7 @@ get_system_info(struct system_info *si) si->ncpus = 1; } si->memory = memory_stats; + si->buf = buf_stats; si->swap = swap_stats;