Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 28 Aug 1996 19:42:28 -0700 (PDT)
From:      "Jonathan M. Bresler" <jmb>
To:        current
Subject:   [Q] mbuf 128 vs 1k bytes ??
Message-ID:  <199608290242.TAA04661@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
an mbuf is 128 bytes.  mbuf clusters are 2k.  per my reading of
/sys/i386/include/param.h

why does "vmstat -m" report mbufs as being 1k in -current ?? are
they allocated in 1kB blocks and then chopped up into 8 pieces?
are mbuf clusters allocated....how...surely not two allocations of
1kB each.  i took a stroll thru vmstat.c, uipc_mbuf.c, /sys/sys/malloc.h,
vm_kern.c vm_page.c, vm_map.c....and i am glad that john dyson has
his head around this code ;))   i sure dont't understand it near
well enough.

from uipc_mbuf.c line 110, i see that mbufs are "allocated" in
units of pages but that only makes it worse....pages are 4kB (param.h
again)

Aspen:[117] uname -a
FreeBSD Aspen.Woc.Atinc.COM 2.2-CURRENT FreeBSD 2.2-CURRENT #0: Wed Aug 21 20:04:37 EDT 1996     jmb@Aspen.Woc.Atinc.COM:/usr/src/sys/compile/ASPEN  i386
Aspen:[118] vmstat -m | more
[snip]
Memory usage type by bucket size
Size  Type(s)
[snip]
  1K  mbuf, devbuf, namei, UFS mount, VM pgdata, temp, BIO buffer
[snip]
Memory statistics by type                          Type  Kern
        Type  InUse MemUse HighUse  Limit Requests Limit Limit Size(s)
	 mbuf     1     1K      1K  8948K        1    0     0  1K

freefall jmb[106] uname -a
FreeBSD freefall.freebsd.org 2.1.5-RELEASE FreeBSD 2.1.5-RELEASE #0: Thu Aug  8 07:07:41 PDT 1996     davidg@freefall.freebsd.org:/f/src/sys/compile/FREEFALL  i386
freefall jmb[107] vmstat -m | more
[snip]
Memory usage type by bucket size
Size  Type(s)
[snip]
 128  mbuf, devbuf, pcb, routetbl, fragtbl, zombie, ifaddr, soopts, cred,
	  vnodes, VM map, VM object, VM pgdata, file desc, LFS segment,
	  NFS srvsock, ip_moptions, ISOFS node, temp, ttys
[snip]
  4K  mbuf, devbuf, VM pgdata, temp
Memory statistics by type                          Type  Kern
        Type  InUse MemUse HighUse  Limit Requests Limit Limit Size(s)
         mbuf   197    29K    121K 19661K 49212373    0     0  128,4K

4K--?????
from /sys/i386/include/param.h

/*
 * Constants related to network buffer management.
 * MCLBYTES must be no larger than CLBYTES (the software page size), and,
 * on machines that exchange pages of input or output buffers with mbuf
 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
 * of the hardware page size.
 */
#ifndef MSIZE
#define MSIZE           128             /* size of an mbuf */
#endif  /* MSIZE */

#ifndef MCLSHIFT
#define MCLSHIFT        11              /* convert bytes to m_buf clusters */
#endif  /* MCLSHIFT */
#define MCLBYTES        (1 << MCLSHIFT) /* size of an m_buf cluster */
#define MCLOFSET        (MCLBYTES - 1)  /* offset within an m_buf cluster */

jmb

-- 
Jonathan M. Bresler           FreeBSD Postmaster             jmb@FreeBSD.ORG
FreeBSD--4.4BSD Unix for PC clones, source included. http://www.freebsd.org/
PGP 2.6.2 Fingerprint:      31 57 41 56 06 C1 40 13  C5 1C E3 E5 DC 62 0E FB



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608290242.TAA04661>