aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJeff Roberson <jeff@FreeBSD.org>2019-12-22 04:21:16 +0000
committerJeff Roberson <jeff@FreeBSD.org>2019-12-22 04:21:16 +0000
commitbef91632dae0587cbee178a68ca5d7ec4942e7ce (patch)
treeeb330c4141de548870b3eb0df8e777b3ed93d83f /sys
parent85b4c344c8c69ff7993bc0ac833aaf9a8108b88d (diff)
downloadsrc-bef91632dae0587cbee178a68ca5d7ec4942e7ce.tar.gz
src-bef91632dae0587cbee178a68ca5d7ec4942e7ce.zip
Move vm_fault busy logic into its own function for clarity and re-use by
later changes. Reviewed by: kib, markj Differential Revision: https://reviews.freebsd.org/D22820
Notes
Notes: svn path=/head/; revision=355997
Diffstat (limited to 'sys')
-rw-r--r--sys/vm/vm_fault.c71
1 files changed, 36 insertions, 35 deletions
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 80c7bd4fd2f1..fb86b2591a41 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -684,6 +684,41 @@ vm_fault_lock_vnode(struct faultstate *fs)
return (KERN_RESOURCE_SHORTAGE);
}
+/*
+ * Wait/Retry if the page is busy. We have to do this if the page is
+ * either exclusive or shared busy because the vm_pager may be using
+ * read busy for pageouts (and even pageins if it is the vnode pager),
+ * and we could end up trying to pagein and pageout the same page
+ * simultaneously.
+ *
+ * We can theoretically allow the busy case on a read fault if the page
+ * is marked valid, but since such pages are typically already pmap'd,
+ * putting that special case in might be more effort then it is worth.
+ * We cannot under any circumstances mess around with a shared busied
+ * page except, perhaps, to pmap it.
+ */
+static void
+vm_fault_busy_sleep(struct faultstate *fs)
+{
+ /*
+ * Reference the page before unlocking and
+ * sleeping so that the page daemon is less
+ * likely to reclaim it.
+ */
+ vm_page_aflag_set(fs->m, PGA_REFERENCED);
+ if (fs->object != fs->first_object) {
+ fault_page_release(&fs->first_m);
+ vm_object_pip_wakeup(fs->first_object);
+ }
+ vm_object_pip_wakeup(fs->object);
+ unlock_map(fs);
+ if (fs->m == vm_page_lookup(fs->object, fs->pindex))
+ vm_page_sleep_if_busy(fs->m, "vmpfw");
+ VM_OBJECT_WUNLOCK(fs->object);
+ VM_CNT_INC(v_intrans);
+ vm_object_deallocate(fs->first_object);
+}
+
int
vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
int fault_flags, vm_page_t *m_hold)
@@ -822,42 +857,8 @@ RetryFault_oom:
*/
fs.m = vm_page_lookup(fs.object, fs.pindex);
if (fs.m != NULL) {
- /*
- * Wait/Retry if the page is busy. We have to do this
- * if the page is either exclusive or shared busy
- * because the vm_pager may be using read busy for
- * pageouts (and even pageins if it is the vnode
- * pager), and we could end up trying to pagein and
- * pageout the same page simultaneously.
- *
- * We can theoretically allow the busy case on a read
- * fault if the page is marked valid, but since such
- * pages are typically already pmap'd, putting that
- * special case in might be more effort then it is
- * worth. We cannot under any circumstances mess
- * around with a shared busied page except, perhaps,
- * to pmap it.
- */
if (vm_page_tryxbusy(fs.m) == 0) {
- /*
- * Reference the page before unlocking and
- * sleeping so that the page daemon is less
- * likely to reclaim it.
- */
- vm_page_aflag_set(fs.m, PGA_REFERENCED);
- if (fs.object != fs.first_object) {
- fault_page_release(&fs.first_m);
- vm_object_pip_wakeup(fs.first_object);
- }
- unlock_map(&fs);
- vm_object_pip_wakeup(fs.object);
- if (fs.m == vm_page_lookup(fs.object,
- fs.pindex)) {
- vm_page_sleep_if_busy(fs.m, "vmpfw");
- }
- VM_OBJECT_WUNLOCK(fs.object);
- VM_CNT_INC(v_intrans);
- vm_object_deallocate(fs.first_object);
+ vm_fault_busy_sleep(&fs);
goto RetryFault;
}