Page MenuHomeFreeBSD

vm_fault: only rely on PG_ZERO when the page was newly allocated
ClosedPublic

Authored by kib on Thu, Nov 27, 8:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 19, 10:12 AM
Unknown Object (File)
Thu, Dec 18, 5:23 AM
Unknown Object (File)
Tue, Dec 16, 12:37 AM
Unknown Object (File)
Mon, Dec 15, 9:58 PM
Unknown Object (File)
Mon, Dec 15, 7:38 PM
Unknown Object (File)
Mon, Dec 15, 5:48 PM
Unknown Object (File)
Mon, Dec 15, 4:10 PM
Unknown Object (File)
Sat, Dec 13, 8:55 PM
Subscribers

Details

Summary
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
new_alloc, and ignore PG_ZERO if the page did not came from the
allocator.

new_alloc tracking is not exact, but good enough for the purpose.


vm_page.h: remove no longer defined (P) locking annotation

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.Thu, Nov 27, 8:48 PM

Before, the de facto synchronization protocol for this field was that flags are set and cleared only by the page allocator. Now the field can be modified while the page is allocated. On its own this is ok, but it's fragile.

What about making vm_page_alloc() handle VM_ALLOC_ZERO like vm_page_alloc_noobj() does? That is, move all zeroing into the allocator, and make the fault handler and other consumers (kmem_*, iommu_pgalloc()) use VM_ALLOC_ZERO instead of checking for PG_ZERO manually.

I think the only real complication from an implementation perspective is the maintenance of the v_ozfod counter...?

kib retitled this revision from vm_page_invalid(): clear PG_ZERO to vm_fault: only rely on PG_ZERO when the page was newly allocated.
kib edited the summary of this revision. (Show Details)

Completely rework the patch: instead of clearing PG_ZERO, track the page source in the fault state.

sys/vm/vm_fault.c
1224 ↗(On Diff #167250)

I would rather have a flag needs_zero or needs_fill, which is set to false in vm_fault_allocate() if PG_ZERO is set immediately after the allocation, and is true by default. That would be somewhat more clear IMO, it describes the intent.

kib marked an inline comment as done.

Switch to m_needs_zeroing

This revision is now accepted and ready to land.Sun, Nov 30, 6:12 PM