From owner-svn-src-all@freebsd.org Thu Jan 23 05:22:03 2020 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 0E68D22CD6E; Thu, 23 Jan 2020 05:22:03 +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 4839cp6ft9z47Dg; Thu, 23 Jan 2020 05:22:02 +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 DFEE69A07; Thu, 23 Jan 2020 05:22:02 +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 00N5M2di074521; Thu, 23 Jan 2020 05:22:02 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00N5M2qm074520; Thu, 23 Jan 2020 05:22:02 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <202001230522.00N5M2qm074520@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Thu, 23 Jan 2020 05:22:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357027 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 357027 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: Thu, 23 Jan 2020 05:22:03 -0000 Author: jeff Date: Thu Jan 23 05:22:02 2020 New Revision: 357027 URL: https://svnweb.freebsd.org/changeset/base/357027 Log: (fault 8/9) Restructure some code to reduce duplication and simplify flow control. Reviewed by: dougm, kib, markj Differential Revision: https://reviews.freebsd.org/D23321 Modified: head/sys/vm/vm_fault.c Modified: head/sys/vm/vm_fault.c ============================================================================== --- head/sys/vm/vm_fault.c Thu Jan 23 05:19:39 2020 (r357026) +++ head/sys/vm/vm_fault.c Thu Jan 23 05:22:02 2020 (r357027) @@ -1359,49 +1359,47 @@ RetryFault: * object without dropping the lock to preserve atomicity of * shadow faults. */ - if (fs.object->type == OBJT_DEFAULT) { - if (vm_fault_next(&fs)) - continue; - /* Don't try to prefault neighboring pages. */ - faultcount = 1; - break; - } + if (fs.object->type != OBJT_DEFAULT) { + /* + * At this point, we have either allocated a new page + * or found an existing page that is only partially + * valid. + * + * We hold a reference on the current object and the + * page is exclusive busied. The exclusive busy + * prevents simultaneous faults and collapses while + * the object lock is dropped. + */ + VM_OBJECT_WUNLOCK(fs.object); - /* - * At this point, we have either allocated a new page or found - * an existing page that is only partially valid. - * - * We hold a reference on the current object and the page is - * exclusive busied. The exclusive busy prevents simultaneous - * faults and collapses while the object lock is dropped. - */ - VM_OBJECT_WUNLOCK(fs.object); + /* + * If the pager for the current object might have + * the page, then determine the number of additional + * pages to read and potentially reprioritize + * previously read pages for earlier reclamation. + * These operations should only be performed once per + * page fault. Even if the current pager doesn't + * have the page, the number of additional pages to + * read will apply to subsequent objects in the + * shadow chain. + */ + if (nera == -1 && !P_KILLED(curproc)) + nera = vm_fault_readahead(&fs); - /* - * If the pager for the current object might have the page, - * then determine the number of additional pages to read and - * potentially reprioritize previously read pages for earlier - * reclamation. These operations should only be performed - * once per page fault. Even if the current pager doesn't - * have the page, the number of additional pages to read will - * apply to subsequent objects in the shadow chain. - */ - if (nera == -1 && !P_KILLED(curproc)) - nera = vm_fault_readahead(&fs); - - rv = vm_fault_getpages(&fs, nera, &behind, &ahead); - if (rv == KERN_SUCCESS) { - faultcount = behind + 1 + ahead; - hardfault = true; - break; /* break to PAGE HAS BEEN FOUND. */ - } - if (rv == KERN_RESOURCE_SHORTAGE) - goto RetryFault; - VM_OBJECT_WLOCK(fs.object); - if (rv == KERN_OUT_OF_BOUNDS) { - fault_page_free(&fs.m); - unlock_and_deallocate(&fs); - return (rv); + rv = vm_fault_getpages(&fs, nera, &behind, &ahead); + if (rv == KERN_SUCCESS) { + faultcount = behind + 1 + ahead; + hardfault = true; + break; /* break to PAGE HAS BEEN FOUND. */ + } + if (rv == KERN_RESOURCE_SHORTAGE) + goto RetryFault; + VM_OBJECT_WLOCK(fs.object); + if (rv == KERN_OUT_OF_BOUNDS) { + fault_page_free(&fs.m); + unlock_and_deallocate(&fs); + return (rv); + } } /*