From owner-freebsd-hackers Thu Feb 15 05:42:50 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id FAA00646 for hackers-outgoing; Thu, 15 Feb 1996 05:42:50 -0800 (PST) Received: from research.gate.nec.co.jp (research.gate.nec.co.jp [202.32.8.49]) by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id FAA00640 for ; Thu, 15 Feb 1996 05:42:43 -0800 (PST) Received: from sbl-gw.sbl.cl.nec.co.jp by research.gate.nec.co.jp (8.7.3+2.6Wbeta5/950912) with SMTP id WAA18702; Thu, 15 Feb 1996 22:42:30 +0900 (JST) Received: from sirius.sbl.cl.nec.co.jp by sbl-gw.sbl.cl.nec.co.jp (8.6.9/3.3W6) with ESMTP id WAA23679; Thu, 15 Feb 1996 22:42:31 +0900 Received: by sirius.sbl.cl.nec.co.jp (8.6.9/3.3W6) with UUCP id WAA16411; Thu, 15 Feb 1996 22:44:13 +0900 Date: Thu, 15 Feb 1996 22:44:13 +0900 From: Naoki Hamada Message-Id: <199602151344.WAA16411@sirius.sbl.cl.nec.co.jp> To: hackers@FreeBSD.ORG Subject: mbuf enhancement patch Sender: owner-hackers@FreeBSD.ORG Precedence: bulk Hello, guys! I found mbuf's are not buffered though mclusters are. So here is my patch for /sys/sys/mbuf.h. This seems to provide me slightly good network performance. -nao --- mbuf.h.orig Thu Feb 15 20:48:22 1996 +++ mbuf.h Thu Feb 15 21:35:27 1996 @@ -165,6 +165,8 @@ /* * mbuf allocation/deallocation macros: * + * MMALLOC(struct mbuf *m, int how, int type) + * allocates an mbuf. * MGET(struct mbuf *m, int how, int type) * allocates an mbuf and initializes it to contain internal data. * @@ -172,8 +174,18 @@ * allocates an mbuf and initializes it to contain a packet header * and internal data. */ +#define MMALLOC(m, how, type) \ + MBUFLOCK( \ + if (mfree == 0) {\ + MALLOC((m), struct mbuf *, MSIZE, mbtypes[type], (how)); \ + } else { \ + (m) = mfree; \ + mfree = (m)->m_next; \ + } \ + ) + #define MGET(m, how, type) { \ - MALLOC((m), struct mbuf *, MSIZE, mbtypes[type], (how)); \ + MMALLOC((m), (how), (type)); \ if (m) { \ (m)->m_type = (type); \ MBUFLOCK(mbstat.m_mtypes[type]++;) \ @@ -186,7 +198,7 @@ } #define MGETHDR(m, how, type) { \ - MALLOC((m), struct mbuf *, MSIZE, mbtypes[type], (how)); \ + MMALLOC((m), (how), (type)); \ if (m) { \ (m)->m_type = (type); \ MBUFLOCK(mbstat.m_mtypes[type]++;) \ @@ -270,7 +282,10 @@ MCLFREE((m)->m_ext.ext_buf); \ } \ (nn) = (m)->m_next; \ - FREE((m), mbtypes[(m)->m_type]); \ + MBUFLOCK ( \ + (m)->m_next = mfree; \ + mfree = (m); \ + ) \ } #endif @@ -358,6 +373,7 @@ }; #ifdef KERNEL +struct mbuf *mfree; extern struct mbuf *mbutl; /* virtual address of mclusters */ extern char *mclrefcnt; /* cluster reference counts */ struct mbstat mbstat;