vm_unix.c (220373) | vm_unix.c (223825) |
---|---|
1/*- 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1991, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. --- 27 unchanged lines hidden (view full) --- 36 * @(#)vm_unix.c 8.1 (Berkeley) 6/11/93 37 */ 38 39/* 40 * Traditional sbrk/grow interface to VM 41 */ 42 43#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1991, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. --- 27 unchanged lines hidden (view full) --- 36 * @(#)vm_unix.c 8.1 (Berkeley) 6/11/93 37 */ 38 39/* 40 * Traditional sbrk/grow interface to VM 41 */ 42 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: head/sys/vm/vm_unix.c 220373 2011-04-05 20:23:59Z trasz $"); | 44__FBSDID("$FreeBSD: head/sys/vm/vm_unix.c 223825 2011-07-06 20:06:44Z trasz $"); |
45 46#include <sys/param.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> 49#include <sys/proc.h> 50#include <sys/racct.h> 51#include <sys/resourcevar.h> 52#include <sys/sysproto.h> --- 59 unchanged lines hidden (view full) --- 112 error = EINVAL; 113 goto done; 114 } 115 if (new > old) { 116 if (vm->vm_map.size + (new - old) > vmemlim) { 117 error = ENOMEM; 118 goto done; 119 } | 45 46#include <sys/param.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> 49#include <sys/proc.h> 50#include <sys/racct.h> 51#include <sys/resourcevar.h> 52#include <sys/sysproto.h> --- 59 unchanged lines hidden (view full) --- 112 error = EINVAL; 113 goto done; 114 } 115 if (new > old) { 116 if (vm->vm_map.size + (new - old) > vmemlim) { 117 error = ENOMEM; 118 goto done; 119 } |
120#ifdef RACCT |
|
120 PROC_LOCK(td->td_proc); 121 error = racct_set(td->td_proc, RACCT_DATA, new - base); 122 if (error != 0) { 123 PROC_UNLOCK(td->td_proc); 124 error = ENOMEM; 125 goto done; 126 } 127 error = racct_set(td->td_proc, RACCT_VMEM, 128 vm->vm_map.size + (new - old)); 129 if (error != 0) { 130 racct_set_force(td->td_proc, RACCT_DATA, old - base); 131 PROC_UNLOCK(td->td_proc); 132 error = ENOMEM; 133 goto done; 134 } 135 PROC_UNLOCK(td->td_proc); | 121 PROC_LOCK(td->td_proc); 122 error = racct_set(td->td_proc, RACCT_DATA, new - base); 123 if (error != 0) { 124 PROC_UNLOCK(td->td_proc); 125 error = ENOMEM; 126 goto done; 127 } 128 error = racct_set(td->td_proc, RACCT_VMEM, 129 vm->vm_map.size + (new - old)); 130 if (error != 0) { 131 racct_set_force(td->td_proc, RACCT_DATA, old - base); 132 PROC_UNLOCK(td->td_proc); 133 error = ENOMEM; 134 goto done; 135 } 136 PROC_UNLOCK(td->td_proc); |
137#endif |
|
136 rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new, 137 VM_PROT_RW, VM_PROT_ALL, 0); 138 if (rv != KERN_SUCCESS) { | 138 rv = vm_map_insert(&vm->vm_map, NULL, 0, old, new, 139 VM_PROT_RW, VM_PROT_ALL, 0); 140 if (rv != KERN_SUCCESS) { |
141#ifdef RACCT |
|
139 PROC_LOCK(td->td_proc); 140 racct_set_force(td->td_proc, RACCT_DATA, old - base); 141 racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); 142 PROC_UNLOCK(td->td_proc); | 142 PROC_LOCK(td->td_proc); 143 racct_set_force(td->td_proc, RACCT_DATA, old - base); 144 racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); 145 PROC_UNLOCK(td->td_proc); |
146#endif |
|
143 error = ENOMEM; 144 goto done; 145 } 146 vm->vm_dsize += btoc(new - old); 147 /* 148 * Handle the MAP_WIREFUTURE case for legacy applications, 149 * by marking the newly mapped range of pages as wired. 150 * We are not required to perform a corresponding --- 9 unchanged lines hidden (view full) --- 160 } 161 } else if (new < old) { 162 rv = vm_map_delete(&vm->vm_map, new, old); 163 if (rv != KERN_SUCCESS) { 164 error = ENOMEM; 165 goto done; 166 } 167 vm->vm_dsize -= btoc(old - new); | 147 error = ENOMEM; 148 goto done; 149 } 150 vm->vm_dsize += btoc(new - old); 151 /* 152 * Handle the MAP_WIREFUTURE case for legacy applications, 153 * by marking the newly mapped range of pages as wired. 154 * We are not required to perform a corresponding --- 9 unchanged lines hidden (view full) --- 164 } 165 } else if (new < old) { 166 rv = vm_map_delete(&vm->vm_map, new, old); 167 if (rv != KERN_SUCCESS) { 168 error = ENOMEM; 169 goto done; 170 } 171 vm->vm_dsize -= btoc(old - new); |
172#ifdef RACCT |
|
168 PROC_LOCK(td->td_proc); 169 racct_set_force(td->td_proc, RACCT_DATA, new - base); 170 racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); 171 PROC_UNLOCK(td->td_proc); | 173 PROC_LOCK(td->td_proc); 174 racct_set_force(td->td_proc, RACCT_DATA, new - base); 175 racct_set_force(td->td_proc, RACCT_VMEM, vm->vm_map.size); 176 PROC_UNLOCK(td->td_proc); |
177#endif |
|
172 } 173done: 174 vm_map_unlock(&vm->vm_map); 175 176 if (do_map_wirefuture) 177 (void) vm_map_wire(&vm->vm_map, old, new, 178 VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); 179 --- 22 unchanged lines hidden --- | 178 } 179done: 180 vm_map_unlock(&vm->vm_map); 181 182 if (do_map_wirefuture) 183 (void) vm_map_wire(&vm->vm_map, old, new, 184 VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES); 185 --- 22 unchanged lines hidden --- |