Subject: Re: Bug in SONIC driver?
To: Bill Studenmund <wrstuden@loki.stanford.edu>
From: Dave Huang <khym@bga.com>
List: port-mac68k
Date: 10/31/1997 16:02:13
On Fri, 31 Oct 1997, Bill Studenmund wrote:
> > 		if (datalen >= MINCLSIZE) {
> > 			MCLGET(m, M_DONTWAIT);
> > 			if ((m->m_flags & M_EXT) == 0) {
> > 				if (top) m_freem(top);
> > 				return (0);
> > 			}
> > 			len = MCLBYTES; /* <--- this thing here */
> > 		}

> I don't think so. MLEN is defined (in sys/sys/mbuf.h) as
> being MSIZE-sizeof(m_hdr) and so they take care of all of the overhead
> implicit in the structure. MCLBYTES is by how much the mbuf cluster
> can be grown by. Also, MSIZE is 128, and MCLBYTES is 2k. I think MLEN
> sounds more like it.

Actually, MLEN is how much data you can fit in a "normal" mbuf (one
allocated with MGET), and MCLBYTES is how much you can fit in an mbuf
cluster (one allocated with MCLGET); mbufs and mbuf clusters are fixed
size, they don't grow. (I just learned that last night, from reading the
red daemon book :) If the amount of data to put in an mbuf is larger than
MINCLBYTES, the (IMO) buggy code allocates a whole mbuf cluster for it,
but only puts MLEN bytes into the whole thing. This ends up allocating way
more mbuf clusters than is needed (and there are only NMBCLUSTERS of them
total), and wasting 95% of the space in 'em.

> What do other drivers do?

am7990.c, elink3.c, and dp8390.c all use MCLBYTES.

Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 22 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++