Too many mbufs

Ruslan Ermilov ru at freebsd.org
Fri Nov 19 12:42:12 PST 2004


On Fri, Nov 19, 2004 at 03:21:44PM -0500, Chris McDermott wrote:
> > Would you people please include at least a `uname -a`
> > with these posts, even better state the motherboard
> > you're running with.   I am NOT seeing this with
> > a Tyan s2882, dual 244, with 4GB memory, on 5.3-R #0.
> 
> I'm having the same problem, and it seems to be related to
> kern.ipc.mbstat. I don't see kern.ipc.mbstat in the output of sysctl
> -a.
> 
You'd need "sysctl -ax" to print it.

> 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:
> 
> #include <sys/types.h>
> #include <sys/param.h>
> #include <sys/sysctl.h>
> #include <sys/mbuf.h>
> #include <stdio.h>
> 
> int main()
> {
> 	struct mbstat *mbstat;
> 	size_t mlen;
> 	
> 	mlen = sizeof *mbstat;
> 	if( (mbstat = calloc(1,mlen)) == NULL)
> 		perror("calloc");
> 		
> 	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
> 
> System:
> 
> TYAN s2885 dual 242 512M ram 5.3-R
> 
> codefactory# uname -a
> FreeBSD codefactory 5.3-RELEASE FreeBSD 5.3-RELEASE #7: Tue Nov  9
> 23:28:53 EST 2004    
> cmc at codefactory:/usr/src/sys/amd64/compile/CODEFACTORY  amd64
> 
> codefactory# netstat -m
> 18446744073709549940 mbufs in use
> 18446744073709549630/17152 mbuf clusters in use (current/max)
> 0/0/0 sfbufs in use (current/peak/max)
> 18014398509477593 KBytes allocated to network
> 0 requests for sfbufs denied
> 0 requests for sfbufs delayed
> 0 requests for I/O initiated by sendfile
> 0 calls to protocol drain routines


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-amd64/attachments/20041119/97f0e67c/attachment.bin


More information about the freebsd-amd64 mailing list