From nobody Wed Oct 19 17:24:22 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 4MsyJl1FZjz4gStX; Wed, 19 Oct 2022 17:24:23 +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 4MsyJk5fFYz3hkF; Wed, 19 Oct 2022 17:24:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666200262; 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=rWnESvHRioyx5RD00y1g+7Dj0rdccNdBOknWMm94+38=; b=roc7Ji3HjR/GHuS8Db64tpo8TiEjsPCuIs16HnYCLVzj6P0mry6qsIjOcPveksxuJsu+mI yoxnz2RD2xluS11+i6FnLkIdfY7dQdvuBp0uAIbi0LeHj94vvy+YiHHqpUy1/Irm5s2udf H1iBfmplrCACvGJ+JBZTLO0D2PiFLXC6q5up962ny6lAnnTxwZbGp8sSea4A1kv3UBDQoy ASwtP25dgAd8WswW4GzuWujo1vkipHWWgdfHTgUcmR7ipreoi1+zURgNZbo/lVgtU1puFm TrUOetiFUOFKSbH7Et8DjmII36Xpqn65uWo6pcTqYUbcdbdTvQATVrLoQ8mX/Q== 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 4MsyJk4VpNzbj9; Wed, 19 Oct 2022 17:24:22 +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 29JHOMUm073875; Wed, 19 Oct 2022 17:24:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 29JHOMMg073874; Wed, 19 Oct 2022 17:24:22 GMT (envelope-from git) Date: Wed, 19 Oct 2022 17:24:22 GMT Message-Id: <202210191724.29JHOMMg073874@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 934bfc128efa - main - 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/main X-Git-Reftype: branch X-Git-Commit: 934bfc128efae7dec678dd52f75a28ac3538384a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1666200262; 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=rWnESvHRioyx5RD00y1g+7Dj0rdccNdBOknWMm94+38=; b=oNwY4km5UCszRAZdZniDcvc8Irlgyh/Tuxo17y0wLczFhP2+RTiY8AmnoyPdkwcBH1OMF8 /BTsRDjQvk7i/W7Iz6eWjZRJl2Pdf76plhg4eciJwiDwYA6/4Mz2nFDkzDBZAaAPjrFoCM 53n2sOamDJwCAAfJKzlkGUPivmVkij8XuP7BYJjDR2xE3VkKyQKz0ctWfbf1DVSj+8f0pZ /SRAwndcvF/UzQDfUHDNZtFQfgA1bQdooM8HON/3VFrkLB189RjOe2hZB7g15AMjz9PdY5 yADji3jlSxBXq/e1ykr6wCkT2tH9dykKwUVb8SEHBWsVieh46X2Z1PpXoBRgKQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1666200262; a=rsa-sha256; cv=none; b=tv55pVZmkzGLNlaP66KStpb058ntY9PXLf0lLkhSG8NYeDp1milGTgxAnZ+N11yuIJSw9J s44FFiKzR0NiyMaEH2IFM+4NukF54XWUD0bCMmTW1spkVxhFXIsmVZvQh6ghCT3I4jfmJR dBnP+Z6cFgITJHpb0K7QjGgl15zWCOk/oFXWFuMf3eUOzhTmmBDBeVd7GOSNKDUU1eJccc RgJM3UjudiSn3JeTfrquBXBrM5q58kiCSV4Z2H03GH4LgylYVoI209QlbgWG0gk9jfNd8Z 2v49l+AADJzmtY4VSHPCfkcHkPxEAHZZuoxBhvui3zlxOEdU++jWqURZUuq8+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=934bfc128efae7dec678dd52f75a28ac3538384a commit 934bfc128efae7dec678dd52f75a28ac3538384a Author: Konstantin Belousov AuthorDate: 2022-10-18 09:16:36 +0000 Commit: Konstantin Belousov CommitDate: 2022-10-19 17:24:07 +0000 Add vm_page_any_valid() Use it and several other vm_page_*_valid() functions in more places. Suggested and reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37024 --- 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 2dddc7a4c582..eb8980ae4fed 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -6009,7 +6009,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); @@ -6085,7 +6085,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)); /* @@ -6151,7 +6151,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_pt_page_count_adj(pmap, -1); KASSERT(mpte->ref_count == NPTEPG, @@ -7678,7 +7678,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; @@ -7698,7 +7698,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) @@ -8445,7 +8445,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_pt_page_count_adj(pmap, -1); KASSERT(mpte->ref_count == NPTEPG, diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 6e64f7899ba6..077c4329ecaa 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -2847,7 +2847,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), @@ -2922,7 +2922,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))]); /* @@ -2986,7 +2986,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, @@ -4209,7 +4209,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; @@ -4229,7 +4229,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) @@ -4837,7 +4837,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 d6084a5b052b..8895b0f1da5a 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2548,7 +2548,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); } @@ -4226,7 +4226,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 { @@ -4704,7 +4704,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, @@ -5392,7 +5393,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 d2f6a471e8b0..9563f4ac714c 100644 --- a/sys/vm/vm_page.h +++ b/sys/vm/vm_page.h @@ -993,6 +993,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) {