Re: vmstat's entries type

From: Michal Mertl <mime_at_traveller.cz>
Date: Wed, 19 Jul 2006 14:37:15 +0200
Oliver Fromme wrote:
> Michal Mertl <mime_at_traveller.cz> wrote:
>  > Recent thread "2Gb SYSVSHM limitation" reminded me of my recent finding
>  > - fields in struct vmmeter (src/sys/sys/vmmeter.h) are int and not long.
> 
> I'm not authoritative, but I think they should be neither
> int nor long, but uint64_t.

No, it won't work, see below.

>  > On an AMD64 machine which can easily make milion syscalls/second the
>  > counters seem unnecessarily restricted by being 32bit (u_int).
> 
> You don't need an AMD64 machine for that.  I've seen the
> counters in the "vmstat -s" output overflow even on slow
> (by today's measures) intel machines after a certain amount
> of uptime.
> 
>  > P.S.: If a commiter expresses some interest in the subject I can work
>  > out a patch as I just love stats with huge numbers :-).
> 
> Should be fairly easy, I think.  The stats are recorded in
> sysctl variables (e.g. vm.stats.sys.v_swtch), so you have
> to change the data type of the sysctl, then grep the code
> for all occurences that access it (kernel as well as user-
> land).
> 
> However, there's one small problem:  On 32bit architectures
> like i386, a 64bit value can't be changed with a single
> instruction.  That might be an efficiency problem, and you
> also might have to make sure that proper locking is used
> each time the value is accessed.
> 

We had discussions about 64 bit counters several times during the years
(I made a huge patch which turned every network related counter 64bit
and all accesses were made with a macro) and the conclusion was that it
isn't worth it.

64bit numbers are too expensive to do correctly on 32bit machines. When
done incorrectly they can easily get incorrect and that is probably
worse than a simple counter in machine's native word size (which can
still get incorrect on some architectures).

I expect you know that long is usually 64bit wide on 64bit
architectures. The discussion about 64bit counters on 32bit machines
doesn't make much sense when AMD64 is becoming the mainstream
architecture and the right type to use for integers (that can get
"large") is long IMHO.


> Best regards
>    Oliver
Received on Wed Jul 19 2006 - 10:37:27 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:58 UTC