Date: Sun, 22 Dec 2019 04:21:16 +0000 (UTC) From: Jeff Roberson <jeff@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355997 - head/sys/vm Message-ID: <201912220421.xBM4LGQB095081@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jeff Date: Sun Dec 22 04:21:16 2019 New Revision: 355997 URL: https://svnweb.freebsd.org/changeset/base/355997 Log: 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 Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Sun Dec 22 03:19:17 2019 (r355996) +++ head/sys/vm/vm_fault.c Sun Dec 22 04:21:16 2019 (r355997) @@ -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; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912220421.xBM4LGQB095081>