summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_unix.c
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2001-07-04 16:20:28 +0000
committerdillon <dillon@FreeBSD.org>2001-07-04 16:20:28 +0000
commite028603b7e3e4fb35cdf00aab533f3965f4a13cc (patch)
tree7420cce169451a74c5b87963467a4aeff668ed12 /sys/vm/vm_unix.c
parent0b028660051eb7abf4306d34e7fec0e7fde86a28 (diff)
downloadFreeBSD-src-e028603b7e3e4fb35cdf00aab533f3965f4a13cc.zip
FreeBSD-src-e028603b7e3e4fb35cdf00aab533f3965f4a13cc.tar.gz
With Alfred's permission, remove vm_mtx in favor of a fine-grained approach
(this commit is just the first stage). Also add various GIANT_ macros to formalize the removal of Giant, making it easy to test in a more piecemeal fashion. These macros will allow us to test fine-grained locks to a degree before removing Giant, and also after, and to remove Giant in a piecemeal fashion via sysctl's on those subsystems which the authors believe can operate without Giant.
Diffstat (limited to 'sys/vm/vm_unix.c')
-rw-r--r--sys/vm/vm_unix.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c
index 0dfb83e..dcd02e8 100644
--- a/sys/vm/vm_unix.c
+++ b/sys/vm/vm_unix.c
@@ -74,6 +74,9 @@ obreak(p, uap)
register struct vmspace *vm = p->p_vmspace;
vm_offset_t new, old, base;
int rv;
+ int error = 0;
+
+ mtx_lock(&Giant); /* syscall marked mp-safe but isn't */
base = round_page((vm_offset_t) vm->vm_daddr);
new = round_page((vm_offset_t)uap->nsize);
@@ -84,52 +87,46 @@ obreak(p, uap)
* reduce their usage, even if they remain over the limit.
*/
if (new > old &&
- (new - base) > (unsigned) p->p_rlimit[RLIMIT_DATA].rlim_cur)
- return ENOMEM;
- if (new >= VM_MAXUSER_ADDRESS)
- return (ENOMEM);
+ (new - base) > (unsigned) p->p_rlimit[RLIMIT_DATA].rlim_cur) {
+ error = ENOMEM;
+ goto done;
+ }
+ if (new >= VM_MAXUSER_ADDRESS) {
+ error = ENOMEM;
+ goto done;
+ }
} else if (new < base) {
/*
* This is simply an invalid value. If someone wants to
* do fancy address space manipulations, mmap and munmap
* can do most of what the user would want.
*/
- return EINVAL;
+ error = EINVAL;
+ goto done;
}
if (new > old) {
vm_size_t diff;
diff = new - old;
-#ifndef BLEED
- mtx_lock(&Giant);
-#endif
- mtx_lock(&vm_mtx);
rv = vm_map_find(&vm->vm_map, NULL, 0, &old, diff, FALSE,
VM_PROT_ALL, VM_PROT_ALL, 0);
if (rv != KERN_SUCCESS) {
- mtx_unlock(&vm_mtx);
- return (ENOMEM);
+ error = ENOMEM;
+ goto done;
}
vm->vm_dsize += btoc(diff);
- mtx_unlock(&vm_mtx);
-#ifndef BLEED
- mtx_unlock(&Giant);
-#endif
} else if (new < old) {
- mtx_lock(&Giant);
- mtx_lock(&vm_mtx);
rv = vm_map_remove(&vm->vm_map, new, old);
if (rv != KERN_SUCCESS) {
- mtx_unlock(&vm_mtx);
- mtx_unlock(&Giant);
- return (ENOMEM);
+ error = ENOMEM;
+ goto done;
}
vm->vm_dsize -= btoc(old - new);
- mtx_unlock(&vm_mtx);
- mtx_unlock(&Giant);
}
- return (0);
+done:
+ mtx_unlock(&Giant);
+ return (error);
}
#ifndef _SYS_SYSPROTO_H_
@@ -144,6 +141,7 @@ ovadvise(p, uap)
struct proc *p;
struct ovadvise_args *uap;
{
-
+ /* START_GIANT_OPTIONAL */
+ /* END_GIANT_OPTIONAL */
return (EINVAL);
}
OpenPOWER on IntegriCloud