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

Function vm_fault

freebsd/vm/vm_fault.c:1276–1634  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1274}
1275
1276int
1277vm_fault(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
1278 int fault_flags, vm_page_t *m_hold)
1279{
1280 struct faultstate fs;
1281 int ahead, behind, faultcount;
1282 int nera, result, rv;
1283 bool dead, hardfault;
1284
1285 VM_CNT_INC(v_vm_faults);
1286
1287 if ((curthread->td_pflags & TDP_NOFAULTING) != 0)
1288 return (KERN_PROTECTION_FAILURE);
1289
1290 fs.vp = NULL;
1291 fs.vaddr = vaddr;
1292 fs.m_hold = m_hold;
1293 fs.fault_flags = fault_flags;
1294 fs.map = map;
1295 fs.lookup_still_valid = false;
1296 fs.oom = 0;
1297 faultcount = 0;
1298 nera = -1;
1299 hardfault = false;
1300
1301RetryFault:
1302 fs.fault_type = fault_type;
1303
1304 /*
1305 * Find the backing store object and offset into it to begin the
1306 * search.
1307 */
1308 result = vm_fault_lookup(&fs);
1309 if (result != KERN_SUCCESS) {
1310 if (result == KERN_RESOURCE_SHORTAGE)
1311 goto RetryFault;
1312 return (result);
1313 }
1314
1315 /*
1316 * Try to avoid lock contention on the top-level object through
1317 * special-case handling of some types of page faults, specifically,
1318 * those that are mapping an existing page from the top-level object.
1319 * Under this condition, a read lock on the object suffices, allowing
1320 * multiple page faults of a similar type to run in parallel.
1321 */
1322 if (fs.vp == NULL /* avoid locked vnode leak */ &&
1323 (fs.entry->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK) == 0 &&
1324 (fs.fault_flags & (VM_FAULT_WIRE | VM_FAULT_DIRTY)) == 0) {
1325 VM_OBJECT_RLOCK(fs.first_object);
1326 rv = vm_fault_soft_fast(&fs);
1327 if (rv == KERN_SUCCESS)
1328 return (rv);
1329 if (!VM_OBJECT_TRYUPGRADE(fs.first_object)) {
1330 VM_OBJECT_RUNLOCK(fs.first_object);
1331 VM_OBJECT_WLOCK(fs.first_object);
1332 }
1333 } else {

Callers 6

vm_handle_pagingFunction · 0.85
proc_rwmemFunction · 0.85
core_outputFunction · 0.85
vm_map_wire_lockedFunction · 0.85
vm_fault_trapFunction · 0.85

Calls 15

vm_fault_lookupFunction · 0.85
vm_fault_soft_fastFunction · 0.85
vm_object_pip_addFunction · 0.85
vm_fault_allocateFunction · 0.85
unlock_and_deallocateFunction · 0.85
vm_page_lookupFunction · 0.85
vm_page_tryxbusyFunction · 0.85
vm_fault_busy_sleepFunction · 0.85
vm_page_all_validFunction · 0.85
vm_fault_readaheadFunction · 0.85
vm_fault_getpagesFunction · 0.85

Tested by

no test coverage detected