svn commit: r246033 - head/usr.bin/systat

Bruce Evans brde at optusnet.com.au
Mon Jan 28 14:51:20 UTC 2013


On Mon, 28 Jan 2013, Andrey Zonov wrote:

> Log:
>  - Show page faults requiring I/O on vmstat display.

No space is available there for showing it.

> Modified: head/usr.bin/systat/vmstat.c
> ==============================================================================
> --- head/usr.bin/systat/vmstat.c	Mon Jan 28 12:54:53 2013	(r246032)
> +++ head/usr.bin/systat/vmstat.c	Mon Jan 28 12:57:42 2013	(r246033)
> @@ -324,24 +325,25 @@ labelkre(void)
> 	mvprintw(INTSROW, INTSCOL + 1, "Interrupts");
> 	mvprintw(INTSROW + 1, INTSCOL + 6, "total");
>
> -	mvprintw(VMSTATROW, VMSTATCOL + 9, "cow");
> -	mvprintw(VMSTATROW + 1, VMSTATCOL + 9, "zfod");
> -	mvprintw(VMSTATROW + 2, VMSTATCOL + 9, "ozfod");
> -	mvprintw(VMSTATROW + 3, VMSTATCOL + 9 - 1, "%%ozfod");
> -	mvprintw(VMSTATROW + 4, VMSTATCOL + 9, "daefr");
> -	mvprintw(VMSTATROW + 5, VMSTATCOL + 9, "prcfr");
> -	mvprintw(VMSTATROW + 6, VMSTATCOL + 9, "totfr");
> -	mvprintw(VMSTATROW + 7, VMSTATCOL + 9, "react");
> -	mvprintw(VMSTATROW + 8, VMSTATCOL + 9, "pdwak");
> -	mvprintw(VMSTATROW + 9, VMSTATCOL + 9, "pdpgs");
> -	mvprintw(VMSTATROW + 10, VMSTATCOL + 9, "intrn");
> -	mvprintw(VMSTATROW + 11, VMSTATCOL + 9, "wire");
> -	mvprintw(VMSTATROW + 12, VMSTATCOL + 9, "act");
> -	mvprintw(VMSTATROW + 13, VMSTATCOL + 9, "inact");
> -	mvprintw(VMSTATROW + 14, VMSTATCOL + 9, "cache");
> -	mvprintw(VMSTATROW + 15, VMSTATCOL + 9, "free");
> -	if (LINES - 1 > VMSTATROW + 16)
> -		mvprintw(VMSTATROW + 16, VMSTATCOL + 9, "buf");

This is the last possible line on a 25-line display.  On a 24-line
display, it is omitted so that it doesn't mangle or get mangled by the
prompt/status line.  But previous lines are not specially handled, and
neither are other parts of the display.  Also, the interrupt display
may reach the last line of the window, and then it interacts with the
prompt/status line even on a 25-line display.

On a 23-line display, mangling occurs as follows:
- the special case for the "buf" line has no visible effect, since
   this line is outside of the window
- the free "line" and the prompt/status line are both on the last line
   in the window, together with the %busy display and possibly the
   interrupts display.  These mangle each other,

On a 22-line display, the mangling moves up by 1 line and becomes worse.
Now there seems to be a windowing bug.  Some field (the "free" one) is
mispositioned, so the display becomes magled (instead of just truncated)
even when the prompt/status line is not used.

> +	mvprintw(VMSTATROW, VMSTATCOL + 9, "ioflt");

Putting it first unsorts the fields a bit and makes the diff large.

It is not documented in the man page.

> +	mvprintw(VMSTATROW + 1, VMSTATCOL + 9, "cow");
> +	mvprintw(VMSTATROW + 2, VMSTATCOL + 9, "zfod");
> +	mvprintw(VMSTATROW + 3, VMSTATCOL + 9, "ozfod");
> +	mvprintw(VMSTATROW + 4, VMSTATCOL + 9 - 1, "%%ozfod");
> +	mvprintw(VMSTATROW + 5, VMSTATCOL + 9, "daefr");
> +	mvprintw(VMSTATROW + 6, VMSTATCOL + 9, "prcfr");
> +	mvprintw(VMSTATROW + 7, VMSTATCOL + 9, "totfr");
> +	mvprintw(VMSTATROW + 8, VMSTATCOL + 9, "react");
> +	mvprintw(VMSTATROW + 9, VMSTATCOL + 9, "pdwak");
> +	mvprintw(VMSTATROW + 10, VMSTATCOL + 9, "pdpgs");
> +	mvprintw(VMSTATROW + 11, VMSTATCOL + 9, "intrn");
> +	mvprintw(VMSTATROW + 12, VMSTATCOL + 9, "wire");
> +	mvprintw(VMSTATROW + 13, VMSTATCOL + 9, "act");
> +	mvprintw(VMSTATROW + 14, VMSTATCOL + 9, "inact");
> +	mvprintw(VMSTATROW + 15, VMSTATCOL + 9, "cache");
> +	mvprintw(VMSTATROW + 16, VMSTATCOL + 9, "free");
> +	if (LINES - 1 > VMSTATROW + 17)
> +		mvprintw(VMSTATROW + 17, VMSTATCOL + 9, "buf");

Adding a field at the top pushes the "buf" field to the last line of
the window in the most common case of a 25-line display, and makes its
special case useless except for 26-line displays, so mangling from the
"buf" line now occurs in the most common case.

It moves the problems for 22-24 line displays to 23-25 line displays,
respectively.  Now it is the "free" field that needs the special handling
to avoid mangling in the nextmost common case of 24-line displays.  Even
more seriously, the "free" field is much more interesting than the "buf"
field, so we don't want to lose it or have it mangled in a common case. 
The "buf" field really belongs in another group of fields (before "dtbuf")
but is spaced where it is since there is no free space near "dtbuf" but
just 1 line of free space (in the most common case) in the vmmeter fields
column ("buf" also isn't a vmmeter field so it doesn't belong there).  But
now there are 0 lines of free space there.

Since systat output barely works with screen depths other than 24 and
25 lines, omitting the "buf" field after moving its special case to the
"free" field and moving some less important field than "free" to the
end would be the simplest fix.

The "buf" field is worse than useless because it is just the constant
limit on the amount of virtual memory for buffers (nbuf * BKVASIZE).
It is not merely useless, since it wastes space and confuses users
into thinking that it is useful.  top(1) prints it too.  In other OS's
top(1) prints something related to buffer resources that is actually
useful.  The related usful values in FreeBSD are the non-constant
amount of physical memory mapped to buffers and to a lesser extent the
non-constant amount of virtual memory mapped to buffers.  These are
not directly available.  Also the amount of malloced memory pointed
to by buffers (available in vfs.bufmallocspace), and the amount of
disk space cached in VMIO buffers (not directly available, buf "inact"
often approximates it).  But there is no space for these.

"buf" is even more useless with zfs.  So are some of the other fields
printed by systat and top.  I think zfs has its own statistics programs,
but it would be especially difficult to combine these with systat
statistics see the combined resource usage if both zfs and file systems
using the buffer cache/VMIO are active.

Bruce


More information about the svn-src-all mailing list