Date: Sun, 31 Aug 2014 16:37:41 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r270881 - projects/sendfile/sys/kern Message-ID: <201408311637.s7VGbfHF035823@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Sun Aug 31 16:37:41 2014 New Revision: 270881 URL: http://svnweb.freebsd.org/changeset/base/270881 Log: Even if userland requested SF_NOCACHE, ignore it in cases when we are sure that page will be reused. Explain this in comment. Suggested by: David Pfitzner <dpfitzner netflix.com> Sponsored by: Netflix Sponsored by: Nginx, Inc. Modified: projects/sendfile/sys/kern/uipc_syscalls.c Modified: projects/sendfile/sys/kern/uipc_syscalls.c ============================================================================== --- projects/sendfile/sys/kern/uipc_syscalls.c Sun Aug 31 16:14:20 2014 (r270880) +++ projects/sendfile/sys/kern/uipc_syscalls.c Sun Aug 31 16:37:41 2014 (r270881) @@ -3138,16 +3138,26 @@ retry_space: } /* - * Get an mbuf and set it up as having - * EXT_SFBUF/EXT_SFBUF_NOCACHE external storage. + * Get an mbuf and set it up. + * + * SF_NOCACHE sets the page as being freed upon send. + * However, we ignore it for the last page in 'space', + * if the page is truncated, and we got more data to + * send (rem > space), or if we have readahead + * configured (rhpages > 0). */ m0 = m_get(M_WAITOK, MT_DATA); m0->m_ext.ext_buf = (char *)sf_buf_kva(sf); m0->m_ext.ext_size = PAGE_SIZE; m0->m_ext.ext_arg1 = sf; m0->m_ext.ext_arg2 = sfs; - m0->m_ext.ext_type = (flags & SF_NOCACHE) ? - EXT_SFBUF_NOCACHE : EXT_SFBUF; + if ((flags & SF_NOCACHE) == 0 || + (i == npages - 1 && + ((off + space) & PAGE_MASK) && + (rem > space || rhpages > 0))) + m0->m_ext.ext_type = EXT_SFBUF; + else + m0->m_ext.ext_type = EXT_SFBUF_NOCACHE; m0->m_ext.ext_flags = 0; m0->m_flags |= (M_EXT | M_RDONLY); if (nios)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408311637.s7VGbfHF035823>