From owner-svn-src-all@freebsd.org Sun Dec 22 04:21:16 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BF9CF1E7752; Sun, 22 Dec 2019 04:21:16 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47gTnS4SmCz41Nv; Sun, 22 Dec 2019 04:21:16 +0000 (UTC) (envelope-from jeff@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9494B21FEE; Sun, 22 Dec 2019 04:21:16 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xBM4LGOR095082; Sun, 22 Dec 2019 04:21:16 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xBM4LGQB095081; Sun, 22 Dec 2019 04:21:16 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <201912220421.xBM4LGQB095081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Sun, 22 Dec 2019 04:21:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355997 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 355997 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 Dec 2019 04:21:16 -0000 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; }