Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 06 Jul 2003 22:32:06 -0500
From:      Chris Pressey <cpressey@catseye.mb.ca>
To:        stable@freebsd.org
Subject:   Re: Weird vmstat -s stats
Message-ID:  <20030706223206.09a17f29.cpressey@catseye.mb.ca>
In-Reply-To: <44u19zxcg4.fsf@be-well.ilk.org>
References:  <200307051728.24681.me@farid-hajji.de> <44brw8g26e.fsf@be-well.ilk.org> <200307060029.00866.me@farid-hajji.de> <3F07576F.4030105@mac.com> <20030706213540.GU430@gsmx07.alcatel.com.au> <20030706215545.1c29c5ed.cpressey@catseye.mb.ca> <44u19zxcg4.fsf@be-well.ilk.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06 Jul 2003 23:06:35 -0400
Lowell Gilbert <freebsd-stable-local@be-well.no-ip.com> wrote:

> Chris Pressey <cpressey@catseye.mb.ca> writes:
> 
> > 'Scuse me if I'm out of my depth here, but wouldn't the atomic
> > 64-bit update only have to be done when the lower 32 bits were about
> > to wrap(which would be relatively infrequent)?
> 
> Unfortunately, that doesn't quite work.  It opens up a race condition
> where the counter wasn't about to wrap when you do the check, but
> has been advanced again when you do the increment.
> 
> > The check to see if the lower 32 bits were about to wrap would be
> > relatively cheap, too, I'd think.
> 
> Absolutely.  The problem is just that the check itself is not atomic.

OK, that makes sense.

Still, it seems like there are two viable alternatives -

1) use an atomically-updated 32-bit counter, which we know WILL
eventually yield an inaccurate result in a forseeable time frame; or
2) use a 64-bit counter of which only the bottom 32 bits are atomically
updated, which MAY yield an inaccurate result in the same time frame.

Even though it's not 100% guaranteed, the second option does strike me
as a small improvement over the first.

-Chris



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