git: cff67bc43df1 - main - vm_fault: only rely on PG_ZERO when the page was newly allocated
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 08 Dec 2025 22:33:21 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=cff67bc43df14d492ccc08ec92fddceadd069953
commit cff67bc43df14d492ccc08ec92fddceadd069953
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-11-28 15:57:22 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-12-08 22:30:15 +0000
vm_fault: only rely on PG_ZERO when the page was newly allocated
If the fs->m page was found invalid on the object queue, PG_ZERO flag is
stale. Track the source of the page in the new fault state variable
m_needs_zero, and ignore PG_ZERO if the page did not came from the
allocator.
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D53963
---
sys/vm/vm_fault.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index 3bf16778d987..f7318f96f709 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -138,6 +138,7 @@ struct faultstate {
vm_object_t object;
vm_pindex_t pindex;
vm_page_t m;
+ bool m_needs_zeroing;
/* Top-level map object. */
vm_object_t first_object;
@@ -273,6 +274,7 @@ static void
vm_fault_deallocate(struct faultstate *fs)
{
+ fs->m_needs_zeroing = true;
vm_fault_page_release(&fs->m_cow);
vm_fault_page_release(&fs->m);
vm_object_pip_wakeup(fs->object);
@@ -1219,7 +1221,7 @@ vm_fault_zerofill(struct faultstate *fs)
/*
* Zero the page if necessary and mark it valid.
*/
- if ((fs->m->flags & PG_ZERO) == 0) {
+ if (fs->m_needs_zeroing) {
pmap_zero_page(fs->m);
} else {
#ifdef INVARIANTS
@@ -1352,6 +1354,7 @@ vm_fault_allocate(struct faultstate *fs, struct pctrie_iter *pages)
vm_waitpfault(dset, vm_pfault_oom_wait * hz);
return (FAULT_RESTART);
}
+ fs->m_needs_zeroing = (fs->m->flags & PG_ZERO) == 0;
fs->oom_started = false;
return (FAULT_CONTINUE);
@@ -1686,6 +1689,7 @@ vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
fs.fault_flags = fault_flags;
fs.map = map;
fs.lookup_still_valid = false;
+ fs.m_needs_zeroing = true;
fs.oom_started = false;
fs.nera = -1;
fs.can_read_lock = true;