Date: Sat, 20 Nov 2004 21:02:41 +0200 From: Ruslan Ermilov <ru@FreeBSD.org> To: Bruce Evans <bde@zeta.org.au> Cc: Bosko Milekic <bmilekic@FreeBSD.org> Subject: Re: Too many mbufs Message-ID: <20041120190241.GC27369@ip.net.ua> In-Reply-To: <20041120225023.V86199@delplex.bde.org> References: <Pine.BSF.4.60.0411191757010.75856@mail.sbb.co.yu> <bf8d7e4904111912214a86a151@mail.gmail.com> <20041119204208.GA92096@ip.net.ua> <20041120225023.V86199@delplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--da4uJneut+ArUgXk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Nov 20, 2004 at 10:57:30PM +1100, Bruce Evans wrote: > On Fri, 19 Nov 2004, Ruslan Ermilov wrote: >=20 > > 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_mclu= sts); > > > > > > 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) >=20 > The value is obviously negative (since 1844mumble is nearly 2^64), > so the buggy program accidentally displays the correct value. >=20 Yes, sure. ;) > I can't see why the count would be decremented below 0 more on 64-bit > machines than on 32-bit ones. >=20 I glanced at the kern_mbuf.c code yesterday responsible for mbstat maintenance, and if it's supposed to be re-entrant (e.g., by multiple CPUs), then there's a problem as accesses to mbstat aren't arbitrated. I may be equally wrong on this. ;) Cheers, --=20 Ruslan Ermilov ru@FreeBSD.org FreeBSD committer --da4uJneut+ArUgXk Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFBn5TRqRfpzJluFF4RAm/gAJ45Bgl7Wwhs4q3PplxMuqYK6DaPzgCaApL6 Ijx6Wi77Vbkj9mLT3a6+enU= =278O -----END PGP SIGNATURE----- --da4uJneut+ArUgXk--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041120190241.GC27369>