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

Function vm_fault_dirty

freebsd/vm/vm_fault.c:251–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251static void
252vm_fault_dirty(struct faultstate *fs, vm_page_t m)
253{
254 bool need_dirty;
255
256 if (((fs->prot & VM_PROT_WRITE) == 0 &&
257 (fs->fault_flags & VM_FAULT_DIRTY) == 0) ||
258 (m->oflags & VPO_UNMANAGED) != 0)
259 return;
260
261 VM_PAGE_OBJECT_BUSY_ASSERT(m);
262
263 need_dirty = ((fs->fault_type & VM_PROT_WRITE) != 0 &&
264 (fs->fault_flags & VM_FAULT_WIRE) == 0) ||
265 (fs->fault_flags & VM_FAULT_DIRTY) != 0;
266
267 vm_object_set_writeable_dirty(m->object);
268
269 /*
270 * If the fault is a write, we know that this page is being
271 * written NOW so dirty it explicitly to save on
272 * pmap_is_modified() calls later.
273 *
274 * Also, since the page is now dirty, we can possibly tell
275 * the pager to release any swap backing the page.
276 */
277 if (need_dirty && vm_page_set_dirty(m) == 0) {
278 /*
279 * If this is a NOSYNC mmap we do not want to set PGA_NOSYNC
280 * if the page is already dirty to prevent data written with
281 * the expectation of being synced from not being synced.
282 * Likewise if this entry does not request NOSYNC then make
283 * sure the page isn't marked NOSYNC. Applications sharing
284 * data should use the same flags to avoid ping ponging.
285 */
286 if ((fs->entry->eflags & MAP_ENTRY_NOSYNC) != 0)
287 vm_page_aflag_set(m, PGA_NOSYNC);
288 else
289 vm_page_aflag_clear(m, PGA_NOSYNC);
290 }
291
292}
293
294/*
295 * Unlocks fs.first_object and fs.map on success.

Callers 3

vm_fault_soft_fastFunction · 0.85
vm_fault_populateFunction · 0.85
vm_faultFunction · 0.85

Calls 4

vm_page_set_dirtyFunction · 0.85
vm_page_aflag_setFunction · 0.85
vm_page_aflag_clearFunction · 0.85

Tested by

no test coverage detected