- 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
This commit is contained in:
parent
1a71c5b935
commit
3ac7d29722
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245255
@ -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 @@ vm_map_growstack(struct proc *p, vm_offset_t addr)
|
||||
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 @@ vm_map_growstack(struct proc *p, vm_offset_t addr)
|
||||
#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 @@ vm_map_growstack(struct proc *p, vm_offset_t addr)
|
||||
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));
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user