diff options
author | zont <zont@FreeBSD.org> | 2013-01-10 12:43:58 +0000 |
---|---|---|
committer | zont <zont@FreeBSD.org> | 2013-01-10 12:43:58 +0000 |
commit | d2863e4c68a3742c3168311bfe110d8fa15d4de1 (patch) | |
tree | 9b21a99df961ff9d1bdfb325a893008a9368c529 | |
parent | f63fde9f6ff56200aca4579f3579c5dbe586c7bf (diff) | |
download | FreeBSD-src-d2863e4c68a3742c3168311bfe110d8fa15d4de1.zip FreeBSD-src-d2863e4c68a3742c3168311bfe110d8fa15d4de1.tar.gz |
- Reduce kernel size by removing unnecessary pointer indirections.
GENERIC kernel size reduced in 16 bytes and RACCT kernel in 336 bytes.
Suggested by: alc
Reviewed by: alc
Approved by: kib (mentor)
MFC after: 1 week
-rw-r--r-- | sys/vm/vm_map.c | 10 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 17 | ||||
-rw-r--r-- | sys/vm/vm_unix.c | 9 |
3 files changed, 17 insertions, 19 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index f87e5b9..44290c0 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -3281,8 +3281,7 @@ vm_map_stack(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, } if (!old_mlock && map->flags & MAP_WIREFUTURE) { - if (ptoa(vmspace_wired_count(curproc->p_vmspace)) + - init_ssize > lmemlim) { + if (ptoa(pmap_wired_count(map->pmap)) + init_ssize > lmemlim) { vm_map_unlock(map); return (KERN_NO_SPACE); } @@ -3505,8 +3504,7 @@ Retry: grow_amount = limit - ctob(vm->vm_ssize); #endif if (!old_mlock && map->flags & MAP_WIREFUTURE) { - if (ptoa(vmspace_wired_count(p->p_vmspace)) + grow_amount > - lmemlim) { + if (ptoa(pmap_wired_count(map->pmap)) + grow_amount > lmemlim) { vm_map_unlock_read(map); rv = KERN_NO_SPACE; goto out; @@ -3514,7 +3512,7 @@ Retry: #ifdef RACCT PROC_LOCK(p); if (racct_set(p, RACCT_MEMLOCK, - ptoa(vmspace_wired_count(p->p_vmspace)) + grow_amount)) { + ptoa(pmap_wired_count(map->pmap)) + grow_amount)) { PROC_UNLOCK(p); vm_map_unlock_read(map); rv = KERN_NO_SPACE; @@ -3645,7 +3643,7 @@ out: KASSERT(error == 0, ("decreasing RACCT_VMEM failed")); if (!old_mlock) { error = racct_set(p, RACCT_MEMLOCK, - ptoa(vmspace_wired_count(p->p_vmspace))); + ptoa(pmap_wired_count(map->pmap))); KASSERT(error == 0, ("decreasing RACCT_MEMLOCK failed")); } error = racct_set(p, RACCT_STACK, ctob(vm->vm_ssize)); diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 16f331a..05bb8ae 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1038,6 +1038,7 @@ sys_mlock(td, uap) struct proc *proc; vm_offset_t addr, end, last, start; vm_size_t npages, size; + vm_map_t map; unsigned long nsize; int error; @@ -1055,8 +1056,9 @@ sys_mlock(td, uap) if (npages > vm_page_max_wired) return (ENOMEM); proc = td->td_proc; + map = &proc->p_vmspace->vm_map; PROC_LOCK(proc); - nsize = ptoa(npages + vmspace_wired_count(proc->p_vmspace)); + nsize = ptoa(npages + pmap_wired_count(map->pmap)); if (nsize > lim_cur(proc, RLIMIT_MEMLOCK)) { PROC_UNLOCK(proc); return (ENOMEM); @@ -1071,13 +1073,13 @@ sys_mlock(td, uap) if (error != 0) return (ENOMEM); #endif - error = vm_map_wire(&proc->p_vmspace->vm_map, start, end, + error = vm_map_wire(map, start, end, VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES); #ifdef RACCT if (error != KERN_SUCCESS) { PROC_LOCK(proc); racct_set(proc, RACCT_MEMLOCK, - ptoa(vmspace_wired_count(proc->p_vmspace))); + ptoa(pmap_wired_count(map->pmap))); PROC_UNLOCK(proc); } #endif @@ -1151,7 +1153,7 @@ sys_mlockall(td, uap) if (error != KERN_SUCCESS) { PROC_LOCK(td->td_proc); racct_set(td->td_proc, RACCT_MEMLOCK, - ptoa(vmspace_wired_count(td->td_proc->p_vmspace))); + ptoa(pmap_wired_count(map->pmap))); PROC_UNLOCK(td->td_proc); } #endif @@ -1485,16 +1487,15 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot, return (ENOMEM); } if (!old_mlock && map->flags & MAP_WIREFUTURE) { - if (ptoa(vmspace_wired_count(td->td_proc->p_vmspace)) + - size > lim_cur(td->td_proc, RLIMIT_MEMLOCK)) { + if (ptoa(pmap_wired_count(map->pmap)) + size > + lim_cur(td->td_proc, RLIMIT_MEMLOCK)) { racct_set_force(td->td_proc, RACCT_VMEM, map->size); PROC_UNLOCK(td->td_proc); return (ENOMEM); } error = racct_set(td->td_proc, RACCT_MEMLOCK, - ptoa(vmspace_wired_count(td->td_proc->p_vmspace)) + - size); + ptoa(pmap_wired_count(map->pmap)) + size); if (error != 0) { racct_set_force(td->td_proc, RACCT_VMEM, map->size); diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c index d6da08b..d1aa02d 100644 --- a/sys/vm/vm_unix.c +++ b/sys/vm/vm_unix.c @@ -118,7 +118,7 @@ sys_obreak(td, uap) } if (new > old) { if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) { - if (ptoa(vmspace_wired_count(td->td_proc->p_vmspace)) + + if (ptoa(pmap_wired_count(vm->vm_map.pmap)) + (new - old) > lmemlim) { error = ENOMEM; goto done; @@ -146,7 +146,7 @@ sys_obreak(td, uap) } if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) { error = racct_set(td->td_proc, RACCT_MEMLOCK, - ptoa(vmspace_wired_count(td->td_proc->p_vmspace)) + + ptoa(pmap_wired_count(vm->vm_map.pmap)) + (new - old)); if (error != 0) { racct_set_force(td->td_proc, RACCT_DATA, @@ -176,8 +176,7 @@ sys_obreak(td, uap) racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) { racct_set_force(td->td_proc, RACCT_MEMLOCK, - ptoa(vmspace_wired_count( - td->td_proc->p_vmspace))); + ptoa(pmap_wired_count(vm->vm_map.pmap))); } PROC_UNLOCK(td->td_proc); #endif @@ -212,7 +211,7 @@ sys_obreak(td, uap) racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) { racct_set_force(td->td_proc, RACCT_MEMLOCK, - ptoa(vmspace_wired_count(td->td_proc->p_vmspace))); + ptoa(pmap_wired_count(vm->vm_map.pmap))); } PROC_UNLOCK(td->td_proc); #endif |