svn commit: r251523 - head/sys/vm
Gleb Smirnoff
glebius at FreeBSD.org
Sat Jun 8 13:13:41 UTC 2013
Author: glebius
Date: Sat Jun 8 13:13:40 2013
New Revision: 251523
URL: http://svnweb.freebsd.org/changeset/base/251523
Log:
Make sys_mlock() function just a wrapper around vm_mlock() function
that does all the job.
Reviewed by: kib, jilles
Sponsored by: Nginx, Inc.
Modified:
head/sys/vm/vm_extern.h
head/sys/vm/vm_mmap.c
Modified: head/sys/vm/vm_extern.h
==============================================================================
--- head/sys/vm/vm_extern.h Sat Jun 8 13:02:43 2013 (r251522)
+++ head/sys/vm/vm_extern.h Sat Jun 8 13:13:40 2013 (r251523)
@@ -90,5 +90,6 @@ struct sf_buf *vm_imgact_map_page(vm_obj
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_ */
Modified: head/sys/vm/vm_mmap.c
==============================================================================
--- head/sys/vm/vm_mmap.c Sat Jun 8 13:02:43 2013 (r251522)
+++ head/sys/vm/vm_mmap.c Sat Jun 8 13:13:40 2013 (r251523)
@@ -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));
More information about the svn-src-head
mailing list