From nobody Wed Oct 26 00:44:05 2022 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 4MxqnK5V1jz4gWpx; Wed, 26 Oct 2022 00:44:05 +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 4MxqnK4hBPz426h; Wed, 26 Oct 2022 00:44:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666745045; 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=Nyyml+jk4R2sQgBvjIecPv5buPr8k9DGlvuHRj28rnY=; b=pqH8EN2XFRa50MzgjVNw23U0KDyyvS6+Llu26F7vtnLg20gRCWGJnWSV1/xwlWzImrwmEO mUX17WjRESP92093q6ceQHoo4X2ve5tNRLomSBmBvIWehcRIQT1Yn1CqXlKXtVSziEafmK vQJ4rm6Tj9frPvOdXis53/mbwfSqLxnKgsvXRYqeTN5QSNrYaYyweaVFSXafOxUVFNhnav 6vecd2OgPJ1Hdv1/P+JrTITo9l+ryGQHO4q1raIgyrPQx4iB2tbolNcIHfVvzRLGDJZzbj aEaMJkPNommEBHv+cpyj5rZyfQkWfU4JO59jRGOdieTx9uK+lmWzt8lK2gOtpA== 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 4MxqnK3f3szy3K; Wed, 26 Oct 2022 00:44:05 +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 29Q0i5YQ029634; Wed, 26 Oct 2022 00:44:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29Q0i5ko029633; Wed, 26 Oct 2022 00:44:05 GMT (envelope-from git) Date: Wed, 26 Oct 2022 00:44:05 GMT Message-Id: <202210260044.29Q0i5ko029633@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 3e21b5093004 - stable/13 - Add vm_page_any_valid() 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3e21b50930046fcc03fce56444b86f59c0a915a1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666745045; 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=Nyyml+jk4R2sQgBvjIecPv5buPr8k9DGlvuHRj28rnY=; b=BjVDCdIsgnGm635cWd36pgrfAe1FQXnLGtp7JBlMC5rmZ+UhOUdMnJ9XWohgAX26i8k1NN Gm194BmXRDomm2dwAHJmiNYKCv3SLbyIcSJf83VdMdD5UMGW8v2joysP9DjkX6xZADSMgT wh4UUlJZxxgbKpvSv7U5Pbdq8j7aB55uSN/yM6CmN74XUXoMk4oUTJFIuPU3SWf7J0BHEn S27IDLzBviHGmt6RsjWmI9NHbL0DJlcZibExxU+l+48lXprwin5ng9HphY8nIEf+kqVtcp buVkZEdAg0AYvjXp0TOS0GS8dHfch0CuLNRlNeLdKSC12Lb5MGb621ULVmkEkw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666745045; a=rsa-sha256; cv=none; b=FIEL68qFue/07Genr2itWMq6GtnqV2MDcUKL+h/CjTDdJk3svBY4sH00aYowBm3eoCc4AU /pK42MJwdsvlHx60mTtE/8yBIAxDDyzl157WPGNI7QaoUfqqvEMC2iIpaFTRwp2xVkpGKg 97Uv65ry3pjyXiYg3F4+WmfoFqw37OMNLKZ+NfCTYn2ARq8m7ui2+MYrjNJHy7yhP7aWY2 xvYF53ejQJ2hTQXpgqepHuIsCL2GLFwk27yqw5KFS4hF0e2dcpMc4mVJy4rjvdTTSkRCjN /zsFBO7A+5rZOt11N5+kK/y6RH8o4m4PyF0N2RX1R1AlojCYOSj7s7zXXBp2Qw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3e21b50930046fcc03fce56444b86f59c0a915a1 commit 3e21b50930046fcc03fce56444b86f59c0a915a1 Author: Konstantin Belousov AuthorDate: 2022-10-18 09:16:36 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-26 00:43:43 +0000 Add vm_page_any_valid() (cherry picked from commit 934bfc128efae7dec678dd52f75a28ac3538384a) --- sys/amd64/amd64/pmap.c | 12 ++++++------ sys/i386/i386/pmap.c | 12 ++++++------ sys/vm/vm_page.c | 9 +++++---- sys/vm/vm_page.h | 7 +++++++ 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 5d8e636e183d..233c58b83f2d 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -5907,7 +5907,7 @@ pmap_demote_pde_locked(pmap_t pmap, pd_entry_t *pde, vm_offset_t va, * If the page table page is not leftover from an earlier promotion, * initialize it. */ - if (mpte->valid == 0) + if (vm_page_none_valid(mpte)) pmap_fill_ptp(firstpte, newpte); pmap_demote_pde_check(firstpte, newpte); @@ -5983,7 +5983,7 @@ pmap_remove_kernel_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va) * If this page table page was unmapped by a promotion, then it * contains valid mappings. Zero it to invalidate those mappings. */ - if (mpte->valid != 0) + if (vm_page_any_valid(mpte)) pagezero((void *)PHYS_TO_DMAP(mptepa)); /* @@ -6049,7 +6049,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t *pdq, vm_offset_t sva, } else { mpte = pmap_remove_pt_page(pmap, sva); if (mpte != NULL) { - KASSERT(mpte->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(mpte), ("pmap_remove_pde: pte page not promoted")); pmap_resident_count_adj(pmap, -1); KASSERT(mpte->ref_count == NPTEPG, @@ -7560,7 +7560,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object, if (!vm_object_populate(object, pindex, pindex + atop(size))) return; p = vm_page_lookup(object, pindex); - KASSERT(p->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(p), ("pmap_object_init_pt: invalid page %p", p)); pat_mode = p->md.pat_mode; @@ -7580,7 +7580,7 @@ pmap_object_init_pt(pmap_t pmap, vm_offset_t addr, vm_object_t object, p = TAILQ_NEXT(p, listq); for (pa = ptepa + PAGE_SIZE; pa < ptepa + size; pa += PAGE_SIZE) { - KASSERT(p->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(p), ("pmap_object_init_pt: invalid page %p", p)); if (pa != VM_PAGE_TO_PHYS(p) || pat_mode != p->md.pat_mode) @@ -8327,7 +8327,7 @@ pmap_remove_pages(pmap_t pmap) } mpte = pmap_remove_pt_page(pmap, pv->pv_va); if (mpte != NULL) { - KASSERT(mpte->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(mpte), ("pmap_remove_pages: pte page not promoted")); pmap_resident_count_adj(pmap, -1); KASSERT(mpte->ref_count == NPTEPG, diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index a3af2e7180fc..0a70f967f008 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -2865,7 +2865,7 @@ pmap_demote_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va) * If the page table page is not leftover from an earlier promotion, * initialize it. */ - if (mpte->valid == 0) + if (vm_page_none_valid(mpte)) pmap_fill_ptp(firstpte, newpte); KASSERT((*firstpte & PG_FRAME) == (newpte & PG_FRAME), @@ -2940,7 +2940,7 @@ pmap_remove_kernel_pde(pmap_t pmap, pd_entry_t *pde, vm_offset_t va) * If this page table page was unmapped by a promotion, then it * contains valid mappings. Zero it to invalidate those mappings. */ - if (mpte->valid != 0) + if (vm_page_any_valid(mpte)) pagezero((void *)&KPTmap[i386_btop(trunc_4mpage(va))]); /* @@ -3004,7 +3004,7 @@ pmap_remove_pde(pmap_t pmap, pd_entry_t *pdq, vm_offset_t sva, } else { mpte = pmap_remove_pt_page(pmap, sva); if (mpte != NULL) { - KASSERT(mpte->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(mpte), ("pmap_remove_pde: pte page not promoted")); pmap->pm_stats.resident_count--; KASSERT(mpte->ref_count == NPTEPG, @@ -4223,7 +4223,7 @@ __CONCAT(PMTYPE, object_init_pt)(pmap_t pmap, vm_offset_t addr, if (!vm_object_populate(object, pindex, pindex + atop(size))) return; p = vm_page_lookup(object, pindex); - KASSERT(p->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(p), ("pmap_object_init_pt: invalid page %p", p)); pat_mode = p->md.pat_mode; @@ -4243,7 +4243,7 @@ __CONCAT(PMTYPE, object_init_pt)(pmap_t pmap, vm_offset_t addr, p = TAILQ_NEXT(p, listq); for (pa = ptepa + PAGE_SIZE; pa < ptepa + size; pa += PAGE_SIZE) { - KASSERT(p->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(p), ("pmap_object_init_pt: invalid page %p", p)); if (pa != VM_PAGE_TO_PHYS(p) || pat_mode != p->md.pat_mode) @@ -4851,7 +4851,7 @@ __CONCAT(PMTYPE, remove_pages)(pmap_t pmap) } mpte = pmap_remove_pt_page(pmap, pv->pv_va); if (mpte != NULL) { - KASSERT(mpte->valid == VM_PAGE_BITS_ALL, + KASSERT(vm_page_all_valid(mpte), ("pmap_remove_pages: pte page not promoted")); pmap->pm_stats.resident_count--; KASSERT(mpte->ref_count == NPTEPG, diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 2f00657531c2..5d94962c312b 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2522,7 +2522,7 @@ vm_page_alloc_check(vm_page_t m) KASSERT(pmap_page_get_memattr(m) == VM_MEMATTR_DEFAULT, ("page %p has unexpected memattr %d", m, pmap_page_get_memattr(m))); - KASSERT(m->valid == 0, ("free page %p is valid", m)); + KASSERT(vm_page_none_valid(m), ("free page %p is valid", m)); pmap_vm_page_alloc_check(m); } @@ -4205,7 +4205,7 @@ vm_page_release_toq(vm_page_t m, uint8_t nqueue, const bool noreuse) * If we were asked to not cache the page, place it near the head of the * inactive queue so that is reclaimed sooner. */ - if (noreuse || m->valid == 0) { + if (noreuse || vm_page_none_valid(m)) { nqueue = PQ_INACTIVE; nflag = PGA_REQUEUE_HEAD; } else { @@ -4683,7 +4683,8 @@ retrylookup: ma[0] = m; for (i = 1; i < after; i++) { if ((ma[i] = vm_page_next(ma[i - 1])) != NULL) { - if (ma[i]->valid || !vm_page_tryxbusy(ma[i])) + if (vm_page_any_valid(ma[i]) || + !vm_page_tryxbusy(ma[i])) break; } else { ma[i] = vm_page_alloc(object, m->pindex + i, @@ -5371,7 +5372,7 @@ vm_page_is_valid(vm_page_t m, int base, int size) vm_page_bits_t bits; bits = vm_page_bits(base, size); - return (m->valid != 0 && (m->valid & bits) == bits); + return (vm_page_any_valid(m) && (m->valid & bits) == bits); } /* diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h index 7c996d1f55ab..c02db5ee52fc 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -986,6 +986,13 @@ vm_page_all_valid(vm_page_t m) return (m->valid == VM_PAGE_BITS_ALL); } +static inline bool +vm_page_any_valid(vm_page_t m) +{ + + return (m->valid != 0); +} + static inline bool vm_page_none_valid(vm_page_t m) {