Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2006 14:37:15 +0200
From:      Michal Mertl <mime@traveller.cz>
To:        freebsd-current@FreeBSD.ORG
Cc:        Oliver Fromme <olli@lurza.secnetix.de>
Subject:   Re: vmstat's entries type
Message-ID:  <1153312635.1261.22.camel@genius.i.cz>
In-Reply-To: <200607190750.k6J7olwv037263@lurza.secnetix.de>
References:  <200607190750.k6J7olwv037263@lurza.secnetix.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Oliver Fromme wrote:
> Michal Mertl <mime@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





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1153312635.1261.22.camel>