From nobody Wed Dec 08 13:46:26 2021 X-Original-To: dev-commits-src-all@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 B0A4E18D61F3; Wed, 8 Dec 2021 13:46:26 +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 4J8JNf2cr3z3nds; Wed, 8 Dec 2021 13:46:26 +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 35CB414445; Wed, 8 Dec 2021 13:46:26 +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 1B8DkQJL011023; Wed, 8 Dec 2021 13:46:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B8DkQf1011022; Wed, 8 Dec 2021 13:46:26 GMT (envelope-from git) Date: Wed, 8 Dec 2021 13:46:26 GMT Message-Id: <202112081346.1B8DkQf1011022@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 61c3b6832d3b - stable/13 - vm_fault: Move nera into faultstate List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 61c3b6832d3bcd10430b8badac55e0d4fb16db20 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638971186; 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=OvY/7FkVmGtfrde7UaPOC5t2cecb6iVd051n3T8Fg+M=; b=N6tbyODprNhXVMaPUnIbF/Jynv09mM7x+ykzkZSHNz4gsMkbpu9MxeIpN3m+GXMomUh0rK CQJ3FUfCAdyph4ayVjLWWFj0AEwCLT1DnsmeGZ72HBKFBEBICbytuEnPmFc4sTbeNrL3zu MPvXi4YM6/McOuCJiJuSDBBbP7Vv6dbvegfWGNHuKDx/TM5hR5lq4ZjT65KDe1qNxENTN3 7o321sNRhBk/W6xiYm2L7WvYqJenhaoYt76gIrt08uJeCF9esI0YXZtQwqQtPYwrjeE2tL KnwCOBSdKtqnh34wKFBJoNPiHQji+Ylq0pNWktjPCecAV68dcdq956eUzYgUqA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638971186; a=rsa-sha256; cv=none; b=ICo8GmewBs3pj1O93M6mOdVHlzOjyBKPGp41rTkQ6AiLPrVARzwv8ngLyK6IPOg5RzbCn/ UKu9UZJ4HMTGa4+TNY1zjBoDDYbRogMtgy71K1IJP+u6+hvLWgWJv38UpqrAahbRhpzyYp z+tadE+7n6hiUlU72JolWTZwuAybGueGLRvsFbOP2QJu0oGmdDoaf3560UTBfk24WNJf9Z /HPVu3jM6si2qfcbPcGqZozlxG3FRoU3uWt0ISpRL3w7mud2Kbd8kmTWNwW/YFm6wmat+j +ukPXewvxzUKIXdldSYfI21peCD4PkL1rI7oNDSfqXCsEAufOSKVlKes8uczLA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=61c3b6832d3bcd10430b8badac55e0d4fb16db20 commit 61c3b6832d3bcd10430b8badac55e0d4fb16db20 Author: Mark Johnston AuthorDate: 2021-11-24 18:42:32 +0000 Commit: Mark Johnston CommitDate: 2021-12-08 13:39:47 +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 (cherry picked from commit 45c09a74d681cfcad0a556b753cd56f6084ace46) --- 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 646f9ddb9017..d85f4b524b72 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; @@ -1180,7 +1183,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; @@ -1198,6 +1201,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 @@ -1217,15 +1234,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 @@ -1257,8 +1274,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); } @@ -1303,7 +1326,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); @@ -1318,8 +1341,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: @@ -1486,21 +1509,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; @@ -1508,12 +1517,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); } /*