vm_glue.c (220390) | vm_glue.c (223825) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 43 unchanged lines hidden (view full) --- 52 * Carnegie Mellon University 53 * Pittsburgh PA 15213-3890 54 * 55 * any improvements or extensions that they make and grant Carnegie the 56 * rights to redistribute these changes. 57 */ 58 59#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * The Mach Operating System project at Carnegie-Mellon University. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 43 unchanged lines hidden (view full) --- 52 * Carnegie Mellon University 53 * Pittsburgh PA 15213-3890 54 * 55 * any improvements or extensions that they make and grant Carnegie the 56 * rights to redistribute these changes. 57 */ 58 59#include <sys/cdefs.h> |
60__FBSDID("$FreeBSD: head/sys/vm/vm_glue.c 220390 2011-04-06 17:47:22Z jhb $"); | 60__FBSDID("$FreeBSD: head/sys/vm/vm_glue.c 223825 2011-07-06 20:06:44Z trasz $"); |
61 62#include "opt_vm.h" 63#include "opt_kstack_pages.h" 64#include "opt_kstack_max_pages.h" 65 66#include <sys/param.h> 67#include <sys/systm.h> 68#include <sys/limits.h> --- 148 unchanged lines hidden (view full) --- 217 * Also, the sysctl code, which is the only present user 218 * of vslock(), does a hard loop on EAGAIN. 219 */ 220 if (npages + cnt.v_wire_count > vm_page_max_wired) 221 return (EAGAIN); 222#endif 223 error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, 224 VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); | 61 62#include "opt_vm.h" 63#include "opt_kstack_pages.h" 64#include "opt_kstack_max_pages.h" 65 66#include <sys/param.h> 67#include <sys/systm.h> 68#include <sys/limits.h> --- 148 unchanged lines hidden (view full) --- 217 * Also, the sysctl code, which is the only present user 218 * of vslock(), does a hard loop on EAGAIN. 219 */ 220 if (npages + cnt.v_wire_count > vm_page_max_wired) 221 return (EAGAIN); 222#endif 223 error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, 224 VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); |
225#ifdef RACCT |
|
225 if (error != KERN_SUCCESS) { 226 PROC_LOCK(curproc); 227 racct_set(curproc, RACCT_MEMLOCK, 228 ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); 229 PROC_UNLOCK(curproc); 230 } | 226 if (error != KERN_SUCCESS) { 227 PROC_LOCK(curproc); 228 racct_set(curproc, RACCT_MEMLOCK, 229 ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); 230 PROC_UNLOCK(curproc); 231 } |
232#endif |
|
231 /* 232 * Return EFAULT on error to match copy{in,out}() behaviour 233 * rather than returning ENOMEM like mlock() would. 234 */ 235 return (error == KERN_SUCCESS ? 0 : EFAULT); 236} 237 238void 239vsunlock(void *addr, size_t len) 240{ 241 242 /* Rely on the parameter sanity checks performed by vslock(). */ 243 (void)vm_map_unwire(&curproc->p_vmspace->vm_map, 244 trunc_page((vm_offset_t)addr), round_page((vm_offset_t)addr + len), 245 VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); 246 | 233 /* 234 * Return EFAULT on error to match copy{in,out}() behaviour 235 * rather than returning ENOMEM like mlock() would. 236 */ 237 return (error == KERN_SUCCESS ? 0 : EFAULT); 238} 239 240void 241vsunlock(void *addr, size_t len) 242{ 243 244 /* Rely on the parameter sanity checks performed by vslock(). */ 245 (void)vm_map_unwire(&curproc->p_vmspace->vm_map, 246 trunc_page((vm_offset_t)addr), round_page((vm_offset_t)addr + len), 247 VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); 248 |
249#ifdef RACCT |
|
247 PROC_LOCK(curproc); 248 racct_set(curproc, RACCT_MEMLOCK, 249 ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); 250 PROC_UNLOCK(curproc); | 250 PROC_LOCK(curproc); 251 racct_set(curproc, RACCT_MEMLOCK, 252 ptoa(pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)))); 253 PROC_UNLOCK(curproc); |
254#endif |
|
251} 252 253/* 254 * Pin the page contained within the given object at the given offset. If the 255 * page is not resident, allocate and load it using the given object's pager. 256 * Return the pinned page if successful; otherwise, return NULL. 257 */ 258static vm_page_t --- 826 unchanged lines hidden --- | 255} 256 257/* 258 * Pin the page contained within the given object at the given offset. If the 259 * page is not resident, allocate and load it using the given object's pager. 260 * Return the pinned page if successful; otherwise, return NULL. 261 */ 262static vm_page_t --- 826 unchanged lines hidden --- |