Date: Sat, 11 Apr 2015 18:51:42 +0000 (UTC) From: Will Andrews <will@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281442 - head/sys/kern Message-ID: <201504111851.t3BIpgRS071392@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: will Date: Sat Apr 11 18:51:41 2015 New Revision: 281442 URL: https://svnweb.freebsd.org/changeset/base/281442 Log: uiomove_object_page(): Avoid instantiating pages in sparse regions on reads. Check whether the page being requested is either resident or on swap. If not, read from the zero_region instead of instantiating an unnecessary page. This avoids consuming memory for sparse files on tmpfs, when they are read by applications that do not use SEEK_HOLE/SEEK_DATA (which is most of them). Reviewed by: kib MFC after: 1 week Sponsored by: Spectra Logic Modified: head/sys/kern/uipc_shm.c Modified: head/sys/kern/uipc_shm.c ============================================================================== --- head/sys/kern/uipc_shm.c Sat Apr 11 18:45:22 2015 (r281441) +++ head/sys/kern/uipc_shm.c Sat Apr 11 18:51:41 2015 (r281442) @@ -163,6 +163,17 @@ uiomove_object_page(vm_object_t obj, siz VM_OBJECT_WLOCK(obj); /* + * Read I/O without either a corresponding resident page or swap + * page: use zero_region. This is intended to avoid instantiating + * pages on read from a sparse region. + */ + if (uio->uio_rw == UIO_READ && vm_page_lookup(obj, idx) == NULL && + !vm_pager_has_page(obj, idx, NULL, NULL)) { + VM_OBJECT_WUNLOCK(obj); + return (uiomove(__DECONST(void *, zero_region), len, uio)); + } + + /* * Parallel reads of the page content from disk are prevented * by exclusive busy. *
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504111851.t3BIpgRS071392>