Make sys_mlock() function just a wrapper around vm_mlock() function

that does all the job.

Reviewed by:	kib, jilles
Sponsored by:	Nginx, Inc.
This commit is contained in:
Gleb Smirnoff 2013-06-08 13:13:40 +00:00
parent f95c13db04
commit 995d706909
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251523
2 changed files with 11 additions and 5 deletions

View File

@ -90,5 +90,6 @@ struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset);
void vm_imgact_unmap_page(struct sf_buf *sf);
void vm_thread_dispose(struct thread *td);
int vm_thread_new(struct thread *td, int pages);
int vm_mlock(struct proc *, struct ucred *, const void *, size_t);
#endif /* _KERNEL */
#endif /* !_VM_EXTERN_H_ */

View File

@ -1036,18 +1036,24 @@ sys_mlock(td, uap)
struct thread *td;
struct mlock_args *uap;
{
struct proc *proc;
return (vm_mlock(td->td_proc, td->td_ucred, uap->addr, uap->len));
}
int
vm_mlock(struct proc *proc, struct ucred *cred, const void *addr0, size_t len)
{
vm_offset_t addr, end, last, start;
vm_size_t npages, size;
vm_map_t map;
unsigned long nsize;
int error;
error = priv_check(td, PRIV_VM_MLOCK);
error = priv_check_cred(cred, PRIV_VM_MLOCK, 0);
if (error)
return (error);
addr = (vm_offset_t)uap->addr;
size = uap->len;
addr = (vm_offset_t)addr0;
size = len;
last = addr + size;
start = trunc_page(addr);
end = round_page(last);
@ -1056,7 +1062,6 @@ sys_mlock(td, uap)
npages = atop(end - start);
if (npages > vm_page_max_wired)
return (ENOMEM);
proc = td->td_proc;
map = &proc->p_vmspace->vm_map;
PROC_LOCK(proc);
nsize = ptoa(npages + pmap_wired_count(map->pmap));