From owner-freebsd-amd64@FreeBSD.ORG Sat Nov 20 11:57:33 2004 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C7B4116A4CE; Sat, 20 Nov 2004 11:57:33 +0000 (GMT) Received: from mailout1.pacific.net.au (mailout1.pacific.net.au [61.8.0.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F76343D4C; Sat, 20 Nov 2004 11:57:33 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.0.87])iAKBvUGx009457; Sat, 20 Nov 2004 22:57:30 +1100 Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) iAKBvTgb009859; Sat, 20 Nov 2004 22:57:29 +1100 Date: Sat, 20 Nov 2004 22:57:30 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Ruslan Ermilov In-Reply-To: <20041119204208.GA92096@ip.net.ua> Message-ID: <20041120225023.V86199@delplex.bde.org> References: <20041119204208.GA92096@ip.net.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: amd64@FreeBSD.org Subject: Re: Too many mbufs X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Nov 2004 11:57:33 -0000 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