- Improve readability of sys_obreak().
Suggested by: alc Reviewed by: alc Approved by: kib (mentor) MFC after: 1 week
This commit is contained in:
parent
ddd6b3fc33
commit
cde4a72547
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=245296
@ -76,6 +76,7 @@ sys_obreak(td, uap)
|
|||||||
struct obreak_args *uap;
|
struct obreak_args *uap;
|
||||||
{
|
{
|
||||||
struct vmspace *vm = td->td_proc->p_vmspace;
|
struct vmspace *vm = td->td_proc->p_vmspace;
|
||||||
|
vm_map_t map = &vm->vm_map;
|
||||||
vm_offset_t new, old, base;
|
vm_offset_t new, old, base;
|
||||||
rlim_t datalim, lmemlim, vmemlim;
|
rlim_t datalim, lmemlim, vmemlim;
|
||||||
int prot, rv;
|
int prot, rv;
|
||||||
@ -90,7 +91,7 @@ sys_obreak(td, uap)
|
|||||||
|
|
||||||
do_map_wirefuture = FALSE;
|
do_map_wirefuture = FALSE;
|
||||||
new = round_page((vm_offset_t)uap->nsize);
|
new = round_page((vm_offset_t)uap->nsize);
|
||||||
vm_map_lock(&vm->vm_map);
|
vm_map_lock(map);
|
||||||
|
|
||||||
base = round_page((vm_offset_t) vm->vm_daddr);
|
base = round_page((vm_offset_t) vm->vm_daddr);
|
||||||
old = base + ctob(vm->vm_dsize);
|
old = base + ctob(vm->vm_dsize);
|
||||||
@ -103,7 +104,7 @@ sys_obreak(td, uap)
|
|||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (new > vm_map_max(&vm->vm_map)) {
|
if (new > vm_map_max(map)) {
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -117,14 +118,14 @@ sys_obreak(td, uap)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (new > old) {
|
if (new > old) {
|
||||||
if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) {
|
if (!old_mlock && map->flags & MAP_WIREFUTURE) {
|
||||||
if (ptoa(pmap_wired_count(vm->vm_map.pmap)) +
|
if (ptoa(pmap_wired_count(map->pmap)) +
|
||||||
(new - old) > lmemlim) {
|
(new - old) > lmemlim) {
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vm->vm_map.size + (new - old) > vmemlim) {
|
if (map->size + (new - old) > vmemlim) {
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -137,22 +138,21 @@ sys_obreak(td, uap)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
error = racct_set(td->td_proc, RACCT_VMEM,
|
error = racct_set(td->td_proc, RACCT_VMEM,
|
||||||
vm->vm_map.size + (new - old));
|
map->size + (new - old));
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
racct_set_force(td->td_proc, RACCT_DATA, old - base);
|
racct_set_force(td->td_proc, RACCT_DATA, old - base);
|
||||||
PROC_UNLOCK(td->td_proc);
|
PROC_UNLOCK(td->td_proc);
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) {
|
if (!old_mlock && map->flags & MAP_WIREFUTURE) {
|
||||||
error = racct_set(td->td_proc, RACCT_MEMLOCK,
|
error = racct_set(td->td_proc, RACCT_MEMLOCK,
|
||||||
ptoa(pmap_wired_count(vm->vm_map.pmap)) +
|
ptoa(pmap_wired_count(map->pmap)) + (new - old));
|
||||||
(new - old));
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
racct_set_force(td->td_proc, RACCT_DATA,
|
racct_set_force(td->td_proc, RACCT_DATA,
|
||||||
old - base);
|
old - base);
|
||||||
racct_set_force(td->td_proc, RACCT_VMEM,
|
racct_set_force(td->td_proc, RACCT_VMEM,
|
||||||
vm->vm_map.size);
|
map->size);
|
||||||
PROC_UNLOCK(td->td_proc);
|
PROC_UNLOCK(td->td_proc);
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
@ -167,16 +167,15 @@ sys_obreak(td, uap)
|
|||||||
prot |= VM_PROT_EXECUTE;
|
prot |= VM_PROT_EXECUTE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new,
|
rv = vm_map_insert(map, NULL, 0, old, new, prot, VM_PROT_ALL, 0);
|
||||||
prot, VM_PROT_ALL, 0);
|
|
||||||
if (rv != KERN_SUCCESS) {
|
if (rv != KERN_SUCCESS) {
|
||||||
#ifdef RACCT
|
#ifdef RACCT
|
||||||
PROC_LOCK(td->td_proc);
|
PROC_LOCK(td->td_proc);
|
||||||
racct_set_force(td->td_proc, RACCT_DATA, old - base);
|
racct_set_force(td->td_proc, RACCT_DATA, old - base);
|
||||||
racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size);
|
racct_set_force(td->td_proc, RACCT_VMEM, map->size);
|
||||||
if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) {
|
if (!old_mlock && map->flags & MAP_WIREFUTURE) {
|
||||||
racct_set_force(td->td_proc, RACCT_MEMLOCK,
|
racct_set_force(td->td_proc, RACCT_MEMLOCK,
|
||||||
ptoa(pmap_wired_count(vm->vm_map.pmap)));
|
ptoa(pmap_wired_count(map->pmap)));
|
||||||
}
|
}
|
||||||
PROC_UNLOCK(td->td_proc);
|
PROC_UNLOCK(td->td_proc);
|
||||||
#endif
|
#endif
|
||||||
@ -193,13 +192,13 @@ sys_obreak(td, uap)
|
|||||||
*
|
*
|
||||||
* XXX If the pages cannot be wired, no error is returned.
|
* XXX If the pages cannot be wired, no error is returned.
|
||||||
*/
|
*/
|
||||||
if ((vm->vm_map.flags & MAP_WIREFUTURE) == MAP_WIREFUTURE) {
|
if ((map->flags & MAP_WIREFUTURE) == MAP_WIREFUTURE) {
|
||||||
if (bootverbose)
|
if (bootverbose)
|
||||||
printf("obreak: MAP_WIREFUTURE set\n");
|
printf("obreak: MAP_WIREFUTURE set\n");
|
||||||
do_map_wirefuture = TRUE;
|
do_map_wirefuture = TRUE;
|
||||||
}
|
}
|
||||||
} else if (new < old) {
|
} else if (new < old) {
|
||||||
rv = vm_map_delete(&vm->vm_map, new, old);
|
rv = vm_map_delete(map, new, old);
|
||||||
if (rv != KERN_SUCCESS) {
|
if (rv != KERN_SUCCESS) {
|
||||||
error = ENOMEM;
|
error = ENOMEM;
|
||||||
goto done;
|
goto done;
|
||||||
@ -208,19 +207,19 @@ sys_obreak(td, uap)
|
|||||||
#ifdef RACCT
|
#ifdef RACCT
|
||||||
PROC_LOCK(td->td_proc);
|
PROC_LOCK(td->td_proc);
|
||||||
racct_set_force(td->td_proc, RACCT_DATA, new - base);
|
racct_set_force(td->td_proc, RACCT_DATA, new - base);
|
||||||
racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size);
|
racct_set_force(td->td_proc, RACCT_VMEM, map->size);
|
||||||
if (!old_mlock && vm->vm_map.flags & MAP_WIREFUTURE) {
|
if (!old_mlock && map->flags & MAP_WIREFUTURE) {
|
||||||
racct_set_force(td->td_proc, RACCT_MEMLOCK,
|
racct_set_force(td->td_proc, RACCT_MEMLOCK,
|
||||||
ptoa(pmap_wired_count(vm->vm_map.pmap)));
|
ptoa(pmap_wired_count(map->pmap)));
|
||||||
}
|
}
|
||||||
PROC_UNLOCK(td->td_proc);
|
PROC_UNLOCK(td->td_proc);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
vm_map_unlock(&vm->vm_map);
|
vm_map_unlock(map);
|
||||||
|
|
||||||
if (do_map_wirefuture)
|
if (do_map_wirefuture)
|
||||||
(void) vm_map_wire(&vm->vm_map, old, new,
|
(void) vm_map_wire(map, old, new,
|
||||||
VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
|
VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
|
||||||
|
|
||||||
return (error);
|
return (error);
|
||||||
|
Loading…
Reference in New Issue
Block a user