Index: vm/vm_map.c =================================================================== --- vm/vm_map.c (revision 251557) +++ vm/vm_map.c (working copy) @@ -2204,9 +2204,10 @@ * * Implements both kernel and user unwiring. */ + int -vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, - int flags) +vm_map_unwire_count(vm_map_t map, vm_offset_t start, vm_offset_t end, + int flags, vm_offset_t *count) { vm_map_entry_t entry, first_entry, tmp_entry; vm_offset_t saved_start; @@ -2214,6 +2215,7 @@ int rv; boolean_t need_wakeup, result, user_unwire; + *count = 0; user_unwire = (flags & VM_MAP_WIRE_USER) ? TRUE : FALSE; vm_map_lock(map); VM_MAP_RANGE_CHECK(map, start, end); @@ -2328,6 +2330,7 @@ entry->object.vm_object != NULL && (entry->object.vm_object->flags & OBJ_FICTITIOUS) != 0); + *count += entry->end - entry->start; } } KASSERT(entry->eflags & MAP_ENTRY_IN_TRANSITION, @@ -2346,6 +2349,16 @@ return (rv); } +int +vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, + int flags) +{ + vm_offset_t count; + + return vm_map_unwire_count(map, start, end, flags, &count); +} + + /* * vm_map_wire: * Index: vm/vm_map.h =================================================================== --- vm/vm_map.h (revision 251557) +++ vm/vm_map.h (working copy) @@ -388,6 +388,8 @@ void vm_init2 (void); int vm_map_stack (vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int); int vm_map_growstack (struct proc *p, vm_offset_t addr); +int vm_map_unwire_count(vm_map_t map, vm_offset_t start, vm_offset_t end, + int flags, vm_offset_t *count); int vm_map_unwire(vm_map_t map, vm_offset_t start, vm_offset_t end, int flags); int vm_map_wire(vm_map_t map, vm_offset_t start, vm_offset_t end, Index: vm/vm_mmap.c =================================================================== --- vm/vm_mmap.c (revision 251557) +++ vm/vm_mmap.c (working copy) @@ -1222,7 +1222,7 @@ struct thread *td; struct munlock_args *uap; { - vm_offset_t addr, end, last, start; + vm_offset_t addr, end, last, start, unwired; vm_size_t size; int error; @@ -1236,12 +1236,12 @@ end = round_page(last); if (last < addr || end < addr) return (EINVAL); - error = vm_map_unwire(&td->td_proc->p_vmspace->vm_map, start, end, - VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); + error = vm_map_unwire_count(&td->td_proc->p_vmspace->vm_map, start, end, + VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES, &unwired); #ifdef RACCT if (error == KERN_SUCCESS) { PROC_LOCK(td->td_proc); - racct_sub(td->td_proc, RACCT_MEMLOCK, ptoa(end - start)); + racct_sub(td->td_proc, RACCT_MEMLOCK, unwired); PROC_UNLOCK(td->td_proc); } #endif