Page MenuHomeFreeBSD

vm: introduce VM_ALLOC_NOZERO
Needs ReviewPublic

Authored by freebsdphab-AX9_cmx.ietfng.org on Jun 22 2021, 1:43 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 13 2024, 9:17 PM
Unknown Object (File)
Feb 18 2024, 2:33 AM
Unknown Object (File)
Feb 6 2024, 5:11 PM
Unknown Object (File)
Jan 29 2024, 5:04 PM
Unknown Object (File)
Jan 23 2024, 12:35 PM
Unknown Object (File)
Dec 12 2023, 7:32 PM
Unknown Object (File)
Dec 3 2023, 1:15 AM
Unknown Object (File)
Sep 25 2023, 8:27 AM
Subscribers
None

Details

Reviewers
markj
jhb
alc
kib
Summary

This flag to vm_page_grab_valid will cause it to return VM_PAGER_FAIL rather than create a zero page, like VM_ALLOC_NOCREAT. However, unlike VM_ALLOC_NOCREAT, it will not skip page-in of a (partially) invalid page.

This can be used when the kernel is traversing a partially demand-filled/ZFoD swath of the address space without fully emulating faults at each page (and so being seen as demanding zero fill). In particular, if a vm_object has a backing_object, it's not safe to skip over gaps using vm_page_find_least; vm_page_grab_valid (and vm_page_lookup therein) must be used to probe for backing pages in shadowed objects.

This is a lighter-weight change than an alternative option of a vm_page_find_backed_least or similar that produced the pindex of the next non-ZFoD page taking the entire backing hierarchy into account.

If the use of the last VM_ALLOC flag bit is problematic, I suspect this could be given the same value as VM_ALLOC_NORECLAIM, which claims (and appears) to be used only by vm_page_alloc_contig.

Test Plan

Has been in use as part of the experimental CHERI caprevoke work for a while; better suggestions for tests more than welcome.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

Could you please upload a diff with extra context? In particular, see https://wiki.freebsd.org/Phabricator#Create_a_Revision_via_Web_Interface . Ditto for D30864.

Are you saying that you observed non-busy invalid pages on managed object's queues?

BTW the summary contains a typo, I believe: demandling->demanding.

In D30863#694556, @kib wrote:

Are you saying that you observed non-busy invalid pages on managed object's queues?

I believe this situation is possible since at least 4bf95d00cebf4d188d71db759fa492eb6f00b197. I am not sure if this is the scenario which prompted this change. It shouldn't be possible to encounter partially valid pages in a OBJT_DEFAULT/SWAP object, I believe.