Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Feb 1996 22:44:13 +0900
From:      Naoki Hamada <nao@sbl.cl.nec.co.jp>
To:        hackers@FreeBSD.ORG
Subject:   mbuf enhancement patch
Message-ID:  <199602151344.WAA16411@sirius.sbl.cl.nec.co.jp>

next in thread | raw e-mail | index | archive | help
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;



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