diff options
author | truckman <truckman@FreeBSD.org> | 2004-03-15 06:42:40 +0000 |
---|---|---|
committer | truckman <truckman@FreeBSD.org> | 2004-03-15 06:42:40 +0000 |
commit | b7a6af3cc97ed702243c417b87a32b192556f1ca (patch) | |
tree | 85b5951c4e6b33e8155f7f84f90e482148583b0a /sys/vm | |
parent | 4a8aedf7cf357ba29a6e8a503b49e0fa4aaa14ea (diff) | |
download | FreeBSD-src-b7a6af3cc97ed702243c417b87a32b192556f1ca.zip FreeBSD-src-b7a6af3cc97ed702243c417b87a32b192556f1ca.tar.gz |
Revert to the original vslock() and vsunlock() API with the following
exceptions:
Retain the recently added vslock() error return.
The type of the len argument should be size_t, not u_int.
Suggested by: bde
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_extern.h | 4 | ||||
-rw-r--r-- | sys/vm/vm_glue.c | 54 |
2 files changed, 25 insertions, 33 deletions
diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index 9795cc1..e2a87c2d2 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -86,8 +86,8 @@ void vmspace_unshare(struct proc *); void vmspace_free(struct vmspace *); void vmspace_exitfree(struct proc *); void vnode_pager_setsize(struct vnode *, vm_ooffset_t); -int vslock(struct thread *, vm_offset_t, vm_size_t); -int vsunlock(struct thread *, vm_offset_t, vm_size_t); +int vslock(void *, size_t); +void vsunlock(void *, size_t); void vm_object_print(/* db_expr_t */ long, boolean_t, /* db_expr_t */ long, char *); int vm_fault_quick(caddr_t v, int prot); diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index 1b1be53..8ed5bdc 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -187,17 +187,15 @@ useracc(addr, len, rw) * MPSAFE */ int -vslock(td, addr, size) - struct thread *td; - vm_offset_t addr; - vm_size_t size; +vslock(addr, len) + void *addr; + size_t len; { vm_offset_t start, end; - struct proc *proc = td->td_proc; int error, npages; - start = trunc_page(addr); - end = round_page(addr + size); + start = trunc_page((vm_offset_t)addr); + end = round_page((vm_offset_t)addr + len); /* disable wrap around */ if (end <= start) @@ -208,13 +206,13 @@ vslock(td, addr, size) if (npages > vm_page_max_wired) return (ENOMEM); - PROC_LOCK(proc); - if (npages + pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map)) > - atop(lim_cur(proc, RLIMIT_MEMLOCK))) { - PROC_UNLOCK(proc); + PROC_LOCK(curproc); + if (npages + pmap_wired_count(vm_map_pmap(&curproc->p_vmspace->vm_map)) > + atop(lim_cur(curproc, RLIMIT_MEMLOCK))) { + PROC_UNLOCK(curproc); return (ENOMEM); } - PROC_UNLOCK(proc); + PROC_UNLOCK(curproc); #if 0 /* @@ -230,35 +228,29 @@ vslock(td, addr, size) return (EAGAIN); #endif - error = vm_map_wire(&proc->p_vmspace->vm_map, start, end, + error = vm_map_wire(&curproc->p_vmspace->vm_map, start, end, VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); - /* EINVAL is probably a better error to return than ENOMEM */ - return (error == KERN_SUCCESS ? 0 : EINVAL); + /* + * Return EFAULT on error to match copy{in,out}() behaviour + * rather than returning ENOMEM like mlock() would. + */ + return (error == KERN_SUCCESS ? 0 : EFAULT); } /* * MPSAFE */ -int -vsunlock(td, addr, size) - struct thread *td; - vm_offset_t addr; - vm_size_t size; +void +vsunlock(addr, len) + void *addr; + size_t len; { - vm_offset_t start, end; - int error; - - start = trunc_page(addr); - end = round_page(addr + size); - - /* disable wrap around */ - if (end <= start) - return (EINVAL); - error = vm_map_unwire(&td->td_proc->p_vmspace->vm_map, start, end, + /* Rely on the parameter sanity checks performed by vslock(). */ + (void)vm_map_unwire(&curproc->p_vmspace->vm_map, + trunc_page((vm_offset_t)addr), round_page((vm_offset_t)addr + len), VM_MAP_WIRE_SYSTEM|VM_MAP_WIRE_NOHOLES); - return (error == KERN_SUCCESS ? 0 : EINVAL); } /* |