Too many mbufs
Bruce Evans
bde at zeta.org.au
Sat Nov 20 03:57:33 PST 2004
On Fri, 19 Nov 2004, Ruslan Ermilov wrote:
> On Fri, Nov 19, 2004 at 03:21:44PM -0500, Chris McDermott wrote:
> ...
> > If I try and get the value with sysctlbyname() [copied from
> > netstat/mbuf.c], it returns negative values for mbstat->m_mbufs. This
> > negative value does fluctuate with network usage though...
> >
> > Test code:
> > ...
> > if (sysctlbyname("kern.ipc.mbstat", mbstat, &mlen, NULL, 0) < 0)
> > perror("sysctl: retrieving mbstat");
> >
> > printf("mbufs: %d \nclusters: %d\n", mbstat->m_mbufs, mbstat->m_mclusts);
> >
> > return 0;
> > }
> >
> Your code is broken. Both m_mbufs and m_mclusts are of the type
> u_long, so they should be printed with "%lu" specifier. Fix your
> program and try again. (And you should see the same big number.)
>
> > Output:
> >
> > mbufs: -2240
> > clusters: -2686
> > ..
> > codefactory# netstat -m
> > 18446744073709549940 mbufs in use
> > 18446744073709549630/17152 mbuf clusters in use (current/max)
The value is obviously negative (since 1844mumble is nearly 2^64),
so the buggy program accidentally displays the correct value.
I can't see why the count would be decremented below 0 more on 64-bit
machines than on 32-bit ones.
Bruce
More information about the freebsd-amd64
mailing list