From owner-freebsd-net@FreeBSD.ORG Thu Oct 14 17:42:29 2004 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 45BF516A4CE for ; Thu, 14 Oct 2004 17:42:29 +0000 (GMT) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F72243D2D for ; Thu, 14 Oct 2004 17:42:28 +0000 (GMT) (envelope-from glebius@cell.sick.ru) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.12.11/8.12.8) with ESMTP id i9EHgQvd049629 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 14 Oct 2004 21:42:26 +0400 (MSD) (envelope-from glebius@cell.sick.ru) Received: (from glebius@localhost) by cell.sick.ru (8.12.11/8.12.11/Submit) id i9EHgQbB049628 for net@freebsd.org; Thu, 14 Oct 2004 21:42:26 +0400 (MSD) (envelope-from glebius@cell.sick.ru) Date: Thu, 14 Oct 2004 21:42:25 +0400 From: Gleb Smirnoff To: net@freebsd.org Message-ID: <20041014174225.GB49508@cell.sick.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline User-Agent: Mutt/1.5.6i Subject: small tun(4) improvement X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Oct 2004 17:42:29 -0000 --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Collegues, any objections about commiting this improvement to tun(4)? In my ng_device I have a similar function ngdwrite(), which was cut-n-pasted from tunwrite(). And my tests with a patched ng_device have shown 30% speedup on large writes. I don't think it will help tun(4) to be a much faster, since tunwrite() isn't a bottleneck, but I think it is worth considering. The patch was tested on a production PPPoE access concentrator (RELENG_4 however). -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename="if_tun.mcl.diff" Index: if_tun.c =================================================================== RCS file: /home/ncvs/src/sys/net/if_tun.c,v retrieving revision 1.145 diff -u -r1.145 if_tun.c --- if_tun.c 11 Oct 2004 07:28:36 -0000 1.145 +++ if_tun.c 12 Oct 2004 19:28:02 -0000 @@ -760,10 +760,15 @@ tlen = uio->uio_resid; /* get a header mbuf */ - MGETHDR(m, M_DONTWAIT, MT_DATA); + if (uio->uio_resid > MINCLSIZE) { + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + mlen = MCLBYTES; + } else { + MGETHDR(m, M_DONTWAIT, MT_DATA); + mlen = MHLEN; + } if (m == NULL) return (ENOBUFS); - mlen = MHLEN; top = NULL; mp = ⊤ @@ -773,12 +778,17 @@ *mp = m; mp = &m->m_next; if (uio->uio_resid > 0) { - MGET (m, M_DONTWAIT, MT_DATA); + if (uio->uio_resid > MINCLSIZE) { + m = m_getcl(M_DONTWAIT, MT_DATA, 0); + mlen = MCLBYTES; + } else { + MGET (m, M_DONTWAIT, MT_DATA); + mlen = MLEN; + } if (m == 0) { error = ENOBUFS; break; } - mlen = MLEN; } } if (error) { --Qxx1br4bt0+wmkIi--