From owner-svn-src-projects@freebsd.org Thu Jan 7 22:57:16 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 39BDDA67FD7 for ; Thu, 7 Jan 2016 22:57:16 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 10C8E1114; Thu, 7 Jan 2016 22:57:15 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u07MvFT2082689; Thu, 7 Jan 2016 22:57:15 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u07MvFW2082688; Thu, 7 Jan 2016 22:57:15 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201601072257.u07MvFW2082688@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 7 Jan 2016 22:57:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r293388 - projects/sendfile/sys/kern X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Jan 2016 22:57:16 -0000 Author: glebius Date: Thu Jan 7 22:57:14 2016 New Revision: 293388 URL: https://svnweb.freebsd.org/changeset/base/293388 Log: Now that vm_pager_get_pages() provides readahead itself, remove the readahead code from new sendfile(2). Modified: projects/sendfile/sys/kern/uipc_syscalls.c Modified: projects/sendfile/sys/kern/uipc_syscalls.c ============================================================================== --- projects/sendfile/sys/kern/uipc_syscalls.c Thu Jan 7 22:51:59 2016 (r293387) +++ projects/sendfile/sys/kern/uipc_syscalls.c Thu Jan 7 22:57:14 2016 (r293388) @@ -2080,7 +2080,6 @@ struct sf_io { int npages; struct file *sock_fp; struct mbuf *m; - vm_pindex_t last_wired; vm_page_t pa[]; }; @@ -2090,12 +2089,8 @@ sf_iodone(void *arg, vm_page_t *pg, int struct sf_io *sfio = arg; struct socket *so; - for (int i = 0; i < count; i++) { - if (pg[i]->pindex <= sfio->last_wired) - vm_page_xunbusy(pg[i]); - else - vm_page_readahead_finish(pg[i]); - } + for (int i = 0; i < count; i++) + vm_page_xunbusy(pg[i]); if (error) sfio->error = error; @@ -2165,9 +2160,6 @@ sendfile_swapin(vm_object_t obj, struct } } - if (npages > 0) - sfio->last_wired = pa[npages - 1]->pindex; - for (int i = 0; i < npages;) { int j, a, count, rv; @@ -2217,49 +2209,36 @@ sendfile_swapin(vm_object_t obj, struct * We want to pagein as many pages as possible, limited only * by the 'a' hint and actual request. * - * If calculated count yields in value greater than npages, - * then we are doing optional readahead, and we need to grab - * pages for it. Since readahead is optional, we prefer - * failure over sleep and thus say VM_ALLOC_NOWAIT. + * We should not pagein into already valid page, thus if + * 'j' didn't reach last page, trim by that page. + * + * When the pagein fulfils the request, also specify readahead. */ if (j < npages) a = min(a, j - i - 1); - count = min(a + 1, npages + rhpages - i); - for (j = npages; j < i + count; j++) { - pa[j] = vm_page_grab(obj, OFF_TO_IDX(vmoff(j, off)), - VM_ALLOC_NORMAL | VM_ALLOC_NOWAIT); - if (pa[j] == NULL) { - count = j - i; - break; - } - if (pa[j]->valid) { - vm_page_xunbusy(pa[j]); - count = j - i; - break; - } - } + count = min(a + 1, npages - i); - SFSTAT_INC(sf_iocnt); - if (j > npages) { - SFSTAT_ADD(sf_pages_read, npages - i); - SFSTAT_ADD(sf_rhpages_read, j - npages); - } else - SFSTAT_ADD(sf_pages_read, count); - - nios++; refcount_acquire(&sfio->nios); - rv = vm_pager_get_pages_async(obj, pa + i, count, NULL, NULL, + rv = vm_pager_get_pages_async(obj, pa + i, count, NULL, + i + count == npages ? &rhpages : NULL, &sf_iodone, sfio); KASSERT(rv == VM_PAGER_OK, ("%s: pager fail obj %p page %p", __func__, obj, pa[i])); + SFSTAT_INC(sf_iocnt); + SFSTAT_ADD(sf_pages_read, count); + if (i + count == npages) + SFSTAT_ADD(sf_rhpages_read, rhpages); + +#ifdef INVARIANTS for (j = i; j < i + count && j < npages; j++) KASSERT(pa[j] == vm_page_lookup(obj, OFF_TO_IDX(vmoff(j, off))), ("pa[j] %p lookup %p\n", pa[j], vm_page_lookup(obj, OFF_TO_IDX(vmoff(j, off))))); - +#endif i += count; + nios++; } VM_OBJECT_WUNLOCK(obj); @@ -2564,7 +2543,7 @@ retry_space: npages, rhpages); sfio = malloc(sizeof(struct sf_io) + - (rhpages + npages) * sizeof(vm_page_t), M_TEMP, M_WAITOK); + npages * sizeof(vm_page_t), M_TEMP, M_WAITOK); refcount_init(&sfio->nios, 1); sfio->error = 0;