Weird vmstat -s stats
Chris Pressey
cpressey at catseye.mb.ca
Sun Jul 6 20:30:28 PDT 2003
On 06 Jul 2003 23:06:35 -0400
Lowell Gilbert <freebsd-stable-local at be-well.no-ip.com> wrote:
> Chris Pressey <cpressey at 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
More information about the freebsd-stable
mailing list