aboutsummaryrefslogtreecommitdiff
path: root/sys/vm/vm_page.c
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2015-12-16 21:30:45 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2015-12-16 21:30:45 +0000
commitb0cd20172d854584c67cd47461a77e98b43cbcd8 (patch)
treea77a93a364690da41fe0224812a20390e61cd88a /sys/vm/vm_page.c
parentbd6c93e8bd5d442c75110e038db9d0d2ad36e37f (diff)
downloadsrc-b0cd20172d854584c67cd47461a77e98b43cbcd8.tar.gz
src-b0cd20172d854584c67cd47461a77e98b43cbcd8.zip
A change to KPI of vm_pager_get_pages() and underlying VOP_GETPAGES().
o With new KPI consumers can request contiguous ranges of pages, and unlike before, all pages will be kept busied on return, like it was done before with the 'reqpage' only. Now the reqpage goes away. With new interface it is easier to implement code protected from race conditions. Such arrayed requests for now should be preceeded by a call to vm_pager_haspage() to make sure that request is possible. This could be improved later, making vm_pager_haspage() obsolete. Strenghtening the promises on the business of the array of pages allows us to remove such hacks as swp_pager_free_nrpage() and vm_pager_free_nonreq(). o New KPI accepts two integer pointers that may optionally point at values for read ahead and read behind, that a pager may do, if it can. These pages are completely owned by pager, and not controlled by the caller. This shifts the UFS-specific readahead logic from vm_fault.c, which should be file system agnostic, into vnode_pager.c. It also removes one VOP_BMAP() request per hard fault. Discussed with: kib, alc, jeff, scottl Sponsored by: Nginx, Inc. Sponsored by: Netflix
Notes
Notes: svn path=/head/; revision=292373
Diffstat (limited to 'sys/vm/vm_page.c')
-rw-r--r--sys/vm/vm_page.c44
1 files changed, 17 insertions, 27 deletions
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index e5edf77301c4..2e6b56a6d680 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -979,38 +979,28 @@ vm_page_free_zero(vm_page_t m)
/*
* Unbusy and handle the page queueing for a page from the VOP_GETPAGES()
- * array which is not the request page.
+ * array which was optionally read ahead or behind.
*/
void
vm_page_readahead_finish(vm_page_t m)
{
- if (m->valid != 0) {
- /*
- * Since the page is not the requested page, whether
- * it should be activated or deactivated is not
- * obvious. Empirical results have shown that
- * deactivating the page is usually the best choice,
- * unless the page is wanted by another thread.
- */
- vm_page_lock(m);
- if ((m->busy_lock & VPB_BIT_WAITERS) != 0)
- vm_page_activate(m);
- else
- vm_page_deactivate(m);
- vm_page_unlock(m);
- vm_page_xunbusy(m);
- } else {
- /*
- * Free the completely invalid page. Such page state
- * occurs due to the short read operation which did
- * not covered our page at all, or in case when a read
- * error happens.
- */
- vm_page_lock(m);
- vm_page_free(m);
- vm_page_unlock(m);
- }
+ /* We shouldn't put invalid pages on queues. */
+ KASSERT(m->valid != 0, ("%s: %p is invalid", __func__, m));
+
+ /*
+ * Since the page is not the actually needed one, whether it should
+ * be activated or deactivated is not obvious. Empirical results
+ * have shown that deactivating the page is usually the best choice,
+ * unless the page is wanted by another thread.
+ */
+ vm_page_lock(m);
+ if ((m->busy_lock & VPB_BIT_WAITERS) != 0)
+ vm_page_activate(m);
+ else
+ vm_page_deactivate(m);
+ vm_page_unlock(m);
+ vm_page_xunbusy(m);
}
/*