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

Function vm_map_unwire

freebsd/vm/vm_map.c:3253–3386  ·  view source on GitHub ↗

* vm_map_unwire: * * Implements both kernel and user unwiring. */

Source from the content-addressed store, hash-verified

3251 * Implements both kernel and user unwiring.
3252 */
3253int
3254vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end,
3255 int flags)
3256{
3257 vm_map_entry_t entry, first_entry, next_entry, prev_entry;
3258 int rv;
3259 bool holes_ok, need_wakeup, user_unwire;
3260
3261 if (start == end)
3262 return (KERN_SUCCESS);
3263 holes_ok = (flags & VM_MAP_WIRE_HOLESOK) != 0;
3264 user_unwire = (flags & VM_MAP_WIRE_USER) != 0;
3265 vm_map_lock(map);
3266 VM_MAP_RANGE_CHECK(map, start, end);
3267 if (!vm_map_lookup_entry(map, start, &first_entry)) {
3268 if (holes_ok)
3269 first_entry = vm_map_entry_succ(first_entry);
3270 else {
3271 vm_map_unlock(map);
3272 return (KERN_INVALID_ADDRESS);
3273 }
3274 }
3275 rv = KERN_SUCCESS;
3276 for (entry = first_entry; entry->start < end; entry = next_entry) {
3277 if (entry->eflags & MAP_ENTRY_IN_TRANSITION) {
3278 /*
3279 * We have not yet clipped the entry.
3280 */
3281 next_entry = vm_map_entry_in_transition(map, start,
3282 &end, holes_ok, entry);
3283 if (next_entry == NULL) {
3284 if (entry == first_entry) {
3285 vm_map_unlock(map);
3286 return (KERN_INVALID_ADDRESS);
3287 }
3288 rv = KERN_INVALID_ADDRESS;
3289 break;
3290 }
3291 first_entry = (entry == first_entry) ?
3292 next_entry : NULL;
3293 continue;
3294 }
3295 rv = vm_map_clip_start(map, entry, start);
3296 if (rv != KERN_SUCCESS)
3297 break;
3298 rv = vm_map_clip_end(map, entry, end);
3299 if (rv != KERN_SUCCESS)
3300 break;
3301
3302 /*
3303 * Mark the entry in case the map lock is released. (See
3304 * above.)
3305 */
3306 KASSERT((entry->eflags & MAP_ENTRY_IN_TRANSITION) == 0 &&
3307 entry->wiring_thread == NULL,
3308 ("owned map entry %p", entry));
3309 entry->eflags |= MAP_ENTRY_IN_TRANSITION;
3310 entry->wiring_thread = curthread;

Callers 3

vsunlockFunction · 0.85
sys_munlockallFunction · 0.85
kern_munlockFunction · 0.85

Calls 10

vm_map_lookup_entryFunction · 0.85
vm_map_entry_succFunction · 0.85
vm_map_clip_startFunction · 0.85
vm_map_clip_endFunction · 0.85
vm_map_entry_predFunction · 0.85
vm_map_entry_unwireFunction · 0.85
vm_map_try_merge_entriesFunction · 0.85
vm_map_wakeupFunction · 0.85

Tested by

no test coverage detected