From owner-freebsd-atm Thu Oct 17 15:23:39 1996 Return-Path: owner-atm Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id PAA04382 for atm-outgoing; Thu, 17 Oct 1996 15:23:39 -0700 (PDT) Received: from plains.nodak.edu (tinguely@plains.NoDak.edu [134.129.111.64]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id PAA04355; Thu, 17 Oct 1996 15:23:27 -0700 (PDT) Received: (from tinguely@localhost) by plains.nodak.edu (8.7.6/8.7.3) id RAA09577; Thu, 17 Oct 1996 17:23:18 -0500 (CDT) Date: Thu, 17 Oct 1996 17:23:18 -0500 (CDT) From: Mark Tinguely Message-Id: <199610172223.RAA09577@plains.nodak.edu> To: freebsd-atm@freebsd.org, freebsd-hackers@freebsd.org Subject: custom free for external mbuf Sender: owner-atm@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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.