Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Mar 2003 00:25:25 -0800
From:      Luigi Rizzo <rizzo@icir.org>
To:        Hiten Pandya <hiten@unixdaemons.com>
Cc:        arch@FreeBSD.ORG
Subject:   Re: Using m_getcl() in network and nfs code paths
Message-ID:  <20030307002525.A50491@xorpc.icir.org>
In-Reply-To: <20030307080659.GA60937@unixdaemons.com>; from hiten@unixdaemons.com on Fri, Mar 07, 2003 at 03:06:59AM -0500
References:  <20030307004958.GA98917@unixdaemons.com> <20030306212638.A32850@xorpc.icir.org> <20030307080659.GA60937@unixdaemons.com>

next in thread | previous in thread | raw e-mail | index | archive | help
the logic of this code

 	m = (n > X) ? m_getcl(...) : m_get(...)

The following: i have n bytes of data, give me a place large
enough to store them. This can be either a single mbuf or an
mbuf+cluster, depending on the size. The threshold (X) is whatever
fits into the mbuf (which varies depending on whether or not this is
a pkthdr mbuf, but again this is easy to tell inside m_getcl because
you are passing the M_PKTHDR flag).

Now, MINCLSIZE/MHLEN are basically the same thing, and MLEN covers
the case for !M_PKTHDR. But my point is that the programmer should
not bother to know which one to use and instead just let the function
do the right thing.  Fewer chances for bugs, and smaller code.

	cheers
	luigi


On Fri, Mar 07, 2003 at 03:06:59AM -0500, Hiten Pandya wrote:
> Luigi Rizzo (Thu, Mar 06, 2003 at 09:26:38PM -0800) wrote:
> > the number of places where the code does
> > 
> > 	m = (want > X) ? m_getcl(...) : m_get(...)
> > 
> > makes me wonder if we shouldn't perhaps add a 'desired_size'
> > parameter to m_getcl() so we can have the test made in one
> > place and in a consistent way (i..e always use the same
> > threshold X instead of MLEN/MINCLSIZE/MHLEN
> > which i suspect is incorrect somewhere.
> 
> 	Can you provide some examples for this?  I do no exactly follow.
> 	The size checking is always changing.  I have similar changes to
> 	the dev/ and pci/ and netgraph/ tree, and I noticed that it gets
> 	checked against MLEN/MCLBYTES/MHLEN and whatnot... but I do not think
> 	that is a bug, because surely they all represent different
> 	quantities?

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




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