Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jun 2009 09:22:56 +0000 (UTC)
From:      Kip Macy <kmacy@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r193699 - user/kmacy/releng_7_2_fcs/sys/kern
Message-ID:  <200906080922.n589MuOc022144@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmacy
Date: Mon Jun  8 09:22:56 2009
New Revision: 193699
URL: http://svn.freebsd.org/changeset/base/193699

Log:
  try to avoid taking a cache miss on the newly allocated mbuf

Modified:
  user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c

Modified: user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c
==============================================================================
--- user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c	Mon Jun  8 09:19:25 2009	(r193698)
+++ user/kmacy/releng_7_2_fcs/sys/kern/uipc_mbuf.c	Mon Jun  8 09:22:56 2009	(r193699)
@@ -100,6 +100,7 @@ struct mbuf *
 m_getm2(struct mbuf *m, int len, int how, short type, int flags)
 {
 	struct mbuf *mb, *nm = NULL, *mtail = NULL;
+	int size;	
 
 	KASSERT(len >= 0, ("%s: len is < 0", __func__));
 
@@ -112,25 +113,30 @@ m_getm2(struct mbuf *m, int len, int how
 
 	/* Loop and append maximum sized mbufs to the chain tail. */
 	while (len > 0) {
-		if (len > MCLBYTES)
+		if (len > MCLBYTES) {			
 			mb = m_getjcl(how, type, (flags & M_PKTHDR),
 			    MJUMPAGESIZE);
-		else if (len >= MINCLSIZE)
+			size = MJUMPAGESIZE;			
+		} else if (len >= MINCLSIZE) {			
 			mb = m_getcl(how, type, (flags & M_PKTHDR));
-		else if (flags & M_PKTHDR)
+			size = MCLBYTES;			
+		} else if (flags & M_PKTHDR) {			
 			mb = m_gethdr(how, type);
-		else
+			size = MHLEN;
+		} else {			
 			mb = m_get(how, type);
-
+			size = MLEN;
+		}
 		/* Fail the whole operation if one mbuf can't be allocated. */
 		if (mb == NULL) {
 			if (nm != NULL)
 				m_freem(nm);
 			return (NULL);
 		}
-
+		prefetch(mb);		
+		
 		/* Book keeping. */
-		len -= mb->m_size;
+		len -= size;
 		if (mtail != NULL)
 			mtail->m_next = mb;
 		else



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