MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vm_page_zero_invalid

Function vm_page_zero_invalid

freebsd/vm/vm_page.c:5278–5308  ·  view source on GitHub ↗

* vm_page_zero_invalid() * * The kernel assumes that the invalid portions of a page contain * garbage, but such pages can be mapped into memory by user code. * When this occurs, we must zero out the non-valid portions of the * page so user code sees what it expects. * * Pages are most often semi-valid when the end of a file is mapped * into memory and the file's size is not page aligned.

Source from the content-addressed store, hash-verified

5276 * into memory and the file's size is not page aligned.
5277 */
5278void
5279vm_page_zero_invalid(vm_page_t m, boolean_t setvalid)
5280{
5281 int b;
5282 int i;
5283
5284 /*
5285 * Scan the valid bits looking for invalid sections that
5286 * must be zeroed. Invalid sub-DEV_BSIZE'd areas ( where the
5287 * valid bit may be set ) have already been zeroed by
5288 * vm_page_set_validclean().
5289 */
5290 for (b = i = 0; i <= PAGE_SIZE / DEV_BSIZE; ++i) {
5291 if (i == (PAGE_SIZE / DEV_BSIZE) ||
5292 (m->valid & ((vm_page_bits_t)1 << i))) {
5293 if (i > b) {
5294 pmap_zero_page_area(m,
5295 b << DEV_BSHIFT, (i - b) << DEV_BSHIFT);
5296 }
5297 b = i + 1;
5298 }
5299 }
5300
5301 /*
5302 * setvalid is TRUE when we can safely set the zero'd areas
5303 * as being valid. We can do this if there are no cache consistancy
5304 * issues. e.g. it is ok to do with UFS, but not ok to do with NFS.
5305 */
5306 if (setvalid)
5307 vm_page_valid(m);
5308}
5309
5310/*
5311 * vm_page_is_valid:

Callers 4

vfs_bio_getpagesFunction · 0.85
vm_page_grab_validFunction · 0.85
vm_pager_get_pagesFunction · 0.85

Calls 2

vm_page_validFunction · 0.85
pmap_zero_page_areaFunction · 0.50

Tested by

no test coverage detected