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
This commit is contained in:
+5
-1
@@ -138,6 +138,7 @@ struct faultstate {
|
|||||||
vm_object_t object;
|
vm_object_t object;
|
||||||
vm_pindex_t pindex;
|
vm_pindex_t pindex;
|
||||||
vm_page_t m;
|
vm_page_t m;
|
||||||
|
bool m_needs_zeroing;
|
||||||
|
|
||||||
/* Top-level map object. */
|
/* Top-level map object. */
|
||||||
vm_object_t first_object;
|
vm_object_t first_object;
|
||||||
@@ -273,6 +274,7 @@ static void
|
|||||||
vm_fault_deallocate(struct faultstate *fs)
|
vm_fault_deallocate(struct faultstate *fs)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
fs->m_needs_zeroing = true;
|
||||||
vm_fault_page_release(&fs->m_cow);
|
vm_fault_page_release(&fs->m_cow);
|
||||||
vm_fault_page_release(&fs->m);
|
vm_fault_page_release(&fs->m);
|
||||||
vm_object_pip_wakeup(fs->object);
|
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.
|
* 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);
|
pmap_zero_page(fs->m);
|
||||||
} else {
|
} else {
|
||||||
#ifdef INVARIANTS
|
#ifdef INVARIANTS
|
||||||
@@ -1352,6 +1354,7 @@ vm_fault_allocate(struct faultstate *fs, struct pctrie_iter *pages)
|
|||||||
vm_waitpfault(dset, vm_pfault_oom_wait * hz);
|
vm_waitpfault(dset, vm_pfault_oom_wait * hz);
|
||||||
return (FAULT_RESTART);
|
return (FAULT_RESTART);
|
||||||
}
|
}
|
||||||
|
fs->m_needs_zeroing = (fs->m->flags & PG_ZERO) == 0;
|
||||||
fs->oom_started = false;
|
fs->oom_started = false;
|
||||||
|
|
||||||
return (FAULT_CONTINUE);
|
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.fault_flags = fault_flags;
|
||||||
fs.map = map;
|
fs.map = map;
|
||||||
fs.lookup_still_valid = false;
|
fs.lookup_still_valid = false;
|
||||||
|
fs.m_needs_zeroing = true;
|
||||||
fs.oom_started = false;
|
fs.oom_started = false;
|
||||||
fs.nera = -1;
|
fs.nera = -1;
|
||||||
fs.can_read_lock = true;
|
fs.can_read_lock = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user