Re: vmstat -s broken

From: Bruce Evans <bde_at_zeta.org.au>
Date: Wed, 4 Jun 2003 06:09:41 +1000 (EST)
On Tue, 3 Jun 2003, Pete Fritchman wrote:

> ++ 03/06/03 20:47 +0200 - Pawel Worach:
> | I don't know for how long this has been broken but vmstat
> | always reports 0 (zero) for the number of system calls
> | executed which is virtually impossible.
> |
> | This is on a system built
> | FreeBSD darkstar 5.1-CURRENT FreeBSD 5.1-CURRENT #1: Tue Jun  3 02:48:51
> | CEST 2003
> |
> | darkstar# vmstat -s | grep "system calls"
> |
> |         0 system calls
> | darkstar# uptime
>
> FWIW, I also see this behaviour on -current built Feb 13th:
>
> knap.sac(/home/sac1/petef) [258] > vmstat -s | grep system.calls
>         0 system calls
> knap.sac(/home/sac1/petef) [259] > uname -a
> FreeBSD knap.sac.fedex.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0:
> Thu Feb 13 16:26:14 CST 2003
> root_at_knap.sac.fedex.com:/usr/obj/usr/src/sys/SAC-DELL240-5  i386
> knap.sac(/home/sac1/petef) [260] >

Rev.1.67 of vm/vm_meter.c unbroke the sysctl that returns the number of
syscalls, but vmstat(1) accesses cnt.v_syscalls in kmem so it is still
broken.  systat(1) uses the sysctl so it was unbroken.  Using the sysctl
updates cnt.v_syscall, but programs that read it from kmem see a stale
value (the one made by the last call to the sysctl).

I use a different fix which restores the previous code for the SMP
case.  The SMP case remains broken: the count is stored in per-CPU
data (in all cases in -current but only in the SMP case in my version)
so that updating it doesn't require locking or expensive atomic
operations.  Thus there is never any up to date copy of the full count,
and programs that access it in kmem need to know how to assemble it.
None do.

Bruce
Received on Tue Jun 03 2003 - 11:10:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:10 UTC