From owner-svn-src-all@FreeBSD.ORG Thu Jun 14 07:51:38 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 353D7106564A; Thu, 14 Jun 2012 07:51:38 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 1F80B8FC0A; Thu, 14 Jun 2012 07:51:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5E7pb34079425; Thu, 14 Jun 2012 07:51:37 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5E7pb1T079423; Thu, 14 Jun 2012 07:51:37 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201206140751.q5E7pb1T079423@svn.freebsd.org> From: Gleb Smirnoff Date: Thu, 14 Jun 2012 07:51:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237054 - stable/9/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 07:51:38 -0000 Author: glebius Date: Thu Jun 14 07:51:37 2012 New Revision: 237054 URL: http://svn.freebsd.org/changeset/base/237054 Log: Merge 236560 and following 236563,236598 from head: Optimise kern_sendfile(): skip cycling through the entire mbuf chain in m_cat(), storing pointer to last mbuf in chain in local variable and attaching new mbuf to the end of chain. Submitter reports that CPU load dropped for > 10% on a web server serving large files with this optimisation. Submitted by: Sergey Budnevitch Modified: stable/9/sys/kern/uipc_syscalls.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/uipc_syscalls.c ============================================================================== --- stable/9/sys/kern/uipc_syscalls.c Thu Jun 14 07:40:18 2012 (r237053) +++ stable/9/sys/kern/uipc_syscalls.c Thu Jun 14 07:51:37 2012 (r237054) @@ -1962,6 +1962,7 @@ kern_sendfile(struct thread *td, struct * and takes care of the overall progress. */ for (off = uap->offset, rem = uap->nbytes; ; ) { + struct mbuf *mtail = NULL; int loopbytes = 0; int space = 0; int done = 0; @@ -2181,10 +2182,13 @@ retry_space: m0->m_len = xfsize; /* Append to mbuf chain. */ - if (m != NULL) - m_cat(m, m0); + if (mtail != NULL) + mtail->m_next = m0; + else if (m != NULL) + m_last(m)->m_next = m0; else m = m0; + mtail = m0; /* Keep track of bits processed. */ loopbytes += xfsize;