Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Oct 1996 17:23:18 -0500 (CDT)
From:      Mark Tinguely <tinguely@plains.nodak.edu>
To:        freebsd-atm@freebsd.org, freebsd-hackers@freebsd.org
Subject:   custom free for external mbuf
Message-ID:  <199610172223.RAA09577@plains.nodak.edu>

next in thread | raw e-mail | index | archive | help
Religous debate time. :)

in sys/mbuf.h the external mbuf is defined :

struct m_ext {
	caddr_t	ext_buf;		/* start of buffer */
	void	(*ext_free)		/* free routine if not the usual */
		__P((caddr_t, u_int));
	u_int	ext_size;		/* size of buffer, for ext_free */
};
	(then later we see)
#ifdef notyet
#define	MFREE(m, n) \
	{ MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--;) \
	  if ((m)->m_flags & M_EXT) { \
		if ((m)->m_ext.ext_free) \
			(*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
			    (m)->m_ext.ext_size); \
		else \
			MCLFREE((m)->m_ext.ext_buf); \
	  } \
	  (n) = (m)->m_next; \
	  FREE((m), mbtypes[(m)->m_type]); \
	}
	(more deleted)

from greping the rest of the sources, this is *the* place an external
mbuf could call another free routine and it is obviously ifdef out.

what I am thinking about doing is making a new breed of mbuf that is
prebuilt to look like an external mbuf, but is permanent in that its free
routine does not throw away the mbuf external data, mbuf structure, nor the
association between mbuf and external data.

why do I want these permanent mbufs? because I am working with ATM and I don't
want to deal with the allocation, association, tear-down, overhead of many
small PDU packets.

If I add a new flag entry (say M_PERM) and change the MFREE routine (here
I show changes to the "notyet" part of MFREE, the current MFREE changes
would be simular):

	 if ((m)->m_flags & M_EXT) { \
+		if ((m)->m_flags & M_PERM) { \
+		    if ((m)->m_ext.ext_free) \
+			(*((m)->m_ext.ext_free))((m), \	
+			    (m)->m_ext.ext_size); \
+		} \
+		else \
		if ((m)->m_ext.ext_free) \
			(*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
			    (m)->m_ext.ext_size); \
		else \
			MCLFREE((m)->m_ext.ext_buf); \
	  } \
	  (n) = (m)->m_next; \
+	 if ((m)->m_flags & M_PERM == 0) { \
	  FREE((m), mbtypes[(m)->m_type]); \
	 } \
	}

notice, I need to send the address of the mbuf to my recycle "free" program.
and I cannot let it FREE the mbuf lower down in the MFREE routine.

with this, I can send these permanent mbufs anywhere a regular external
mbuf is used (in protocols like IP stack and sockets).

Is there some reason the existing sys/mbuf.h does not allow external mbuf
to call the custom ext_free?

Does anyone have strong reason to not do this (like those extra instruction
will cause significant overhead, etc)?

--mark.



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