From nobody Wed Nov 24 19:03:10 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E6FC018ABA3E; Wed, 24 Nov 2021 19:03:10 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hzr4Z42w8z4X2B; Wed, 24 Nov 2021 19:03:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6AF6573E5; Wed, 24 Nov 2021 19:03:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AOJ3Afn035448; Wed, 24 Nov 2021 19:03:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AOJ3AkP035447; Wed, 24 Nov 2021 19:03:10 GMT (envelope-from git) Date: Wed, 24 Nov 2021 19:03:10 GMT Message-Id: <202111241903.1AOJ3AkP035447@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 45c09a74d681 - main - vm_fault: Move nera into faultstate List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 45c09a74d681cfcad0a556b753cd56f6084ace46 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1637780590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=HADp9/rck+Y5csfdpMpomoHi1YClrCdClJpl4UtfmD4=; b=vLFPWZyHnD4iHRIlKsuk9lrT5yIDSh/rdftJmglU7lUdO+ZtN/LG1cZrJfkPA0Oi8BDTg2 ggyLK+qWynllCntg/+YvquPZ38mAzRyIsA1VcWy8y0+dhvu2KdgUAplSEwdg17Y6drFK3G EjuioOCMKQj4Z3O4Aie09iyzH48qzrxlkSNZYxLCHTXMUQo/CuTBR0loVXEaGnBC7b0cRX oRP/MyMWvK1Q4/CWv3gLjqRly4hhftgIeuIYclrB3thFmsj0h8kZdQxqsGy4cAXzlrbF3Z 2mY+RUFsrMWtSM8IcfjukQJnFj8rKTjIAGbnQxFOcZmxIfVHFhef3ZrtcDXypg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1637780590; a=rsa-sha256; cv=none; b=I7xi1NO41F4r8O9pSAuQG8MGQ19zUd968kn8Yrl3DWAia44H9+fWcZgS3bsg4fj4kkt5Pi un8B9nWn8EnqOMR22uLxYxjAkD8K8eqBOEDKU6hOXxmuo5xIyj58XHn+IdJ8jNfzq6qWca yJfPgG9M3A8trAdl5gPfWlyheG5KRsNfbDtpGuYKTGSEE4lR7pZUJFH7ovQkZ695Zpq+Vv cLtdoG7Bl23XzKQ1P1NNODBogp46KwfRuii/5t172egd1lEb+7kP0wdmvn1Yr0yPbrgP8I xFwLTEHj8EWip0vyvHQ1fQuLsEZSHJVdb3gq/AC9rGqiYQlVOhVTznWxV35yQw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=45c09a74d681cfcad0a556b753cd56f6084ace46 commit 45c09a74d681cfcad0a556b753cd56f6084ace46 Author: Mark Johnston AuthorDate: 2021-11-24 18:42:32 +0000 Commit: Mark Johnston CommitDate: 2021-11-24 19:02:55 +0000 vm_fault: Move nera into faultstate This makes it easier to factor out pieces of vm_fault(). No functional change intended. Obtained from: jeff (object_concurrency patches) Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33016 --- sys/vm/vm_fault.c | 62 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index d459bad78dd8..75868c17d32d 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -125,9 +125,12 @@ struct faultstate { vm_prot_t fault_type; vm_prot_t prot; int fault_flags; + boolean_t wired; + + /* Control state. */ struct timeval oom_start_time; bool oom_started; - boolean_t wired; + int nera; /* Page reference for cow. */ vm_page_t m_cow; @@ -1184,7 +1187,7 @@ vm_fault_allocate(struct faultstate *fs) * pages at the same time. */ static int -vm_fault_getpages(struct faultstate *fs, int nera, int *behindp, int *aheadp) +vm_fault_getpages(struct faultstate *fs, int *behindp, int *aheadp) { vm_offset_t e_end, e_start; int ahead, behind, cluster_offset, rv; @@ -1202,6 +1205,20 @@ vm_fault_getpages(struct faultstate *fs, int nera, int *behindp, int *aheadp) e_end = fs->entry->end; behavior = vm_map_entry_behavior(fs->entry); + /* + * 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 (fs->nera == -1 && !P_KILLED(curproc)) + fs->nera = vm_fault_readahead(fs); + /* * Release the map lock before locking the vnode or * sleeping in the pager. (If the current object has @@ -1221,15 +1238,15 @@ vm_fault_getpages(struct faultstate *fs, int nera, int *behindp, int *aheadp) * Page in the requested page and hint the pager, * that it may bring up surrounding pages. */ - if (nera == -1 || behavior == MAP_ENTRY_BEHAV_RANDOM || + if (fs->nera == -1 || behavior == MAP_ENTRY_BEHAV_RANDOM || P_KILLED(curproc)) { behind = 0; ahead = 0; } else { /* Is this a sequential fault? */ - if (nera > 0) { + if (fs->nera > 0) { behind = 0; - ahead = nera; + ahead = fs->nera; } else { /* * Request a cluster of pages that is @@ -1261,8 +1278,14 @@ vm_fault_getpages(struct faultstate *fs, int nera, int *behindp, int *aheadp) * outside the range of the pager, clean up and return * an error. */ - if (rv == VM_PAGER_ERROR || rv == VM_PAGER_BAD) + if (rv == VM_PAGER_ERROR || rv == VM_PAGER_BAD) { + VM_OBJECT_WLOCK(fs->object); + fault_page_free(&fs->m); + unlock_and_deallocate(fs); return (KERN_OUT_OF_BOUNDS); + } + KASSERT(rv == VM_PAGER_FAIL, + ("%s: unepxected pager error %d", __func__, rv)); return (KERN_NOT_RECEIVER); } @@ -1307,7 +1330,7 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, { struct faultstate fs; int ahead, behind, faultcount; - int nera, result, rv; + int result, rv; bool dead, hardfault; VM_CNT_INC(v_vm_faults); @@ -1322,8 +1345,8 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type, fs.map = map; fs.lookup_still_valid = false; fs.oom_started = false; + fs.nera = -1; faultcount = 0; - nera = -1; hardfault = false; RetryFault: @@ -1490,21 +1513,7 @@ RetryFault: */ 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); - - rv = vm_fault_getpages(&fs, nera, &behind, &ahead); + rv = vm_fault_getpages(&fs, &behind, &ahead); if (rv == KERN_SUCCESS) { faultcount = behind + 1 + ahead; hardfault = true; @@ -1512,12 +1521,9 @@ RetryFault: } 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); + if (rv == KERN_OUT_OF_BOUNDS) return (rv); - } + VM_OBJECT_WLOCK(fs.object); } /*