diff options
| author | 2019-06-21 09:39:48 +0000 | |
|---|---|---|
| committer | 2019-06-21 09:39:48 +0000 | |
| commit | edc99bcd885f4004d6cffdbe82f15aa2eb27ee9c (patch) | |
| tree | 90a5c776fe52a9672304a33b0ce308c3c1f7763f /sys/uvm/uvm_unix.c | |
| parent | Use timeout_add_msec(9) (diff) | |
| download | wireguard-openbsd-edc99bcd885f4004d6cffdbe82f15aa2eb27ee9c.tar.xz wireguard-openbsd-edc99bcd885f4004d6cffdbe82f15aa2eb27ee9c.zip | |
Make resource limit access MP-safe. So far, the copy-on-write sharing
of resource limit structs has been done between processes. By applying
copy-on-write also between threads, threads can read rlimits in
a nearly lock-free manner.
Inspired by code in DragonFly BSD and FreeBSD.
OK mpi@, agreement from jmatthew@ and anton@
Diffstat (limited to '')
| -rw-r--r-- | sys/uvm/uvm_unix.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/uvm/uvm_unix.c b/sys/uvm/uvm_unix.c index 4618ce03559..c9dfd786fab 100644 --- a/sys/uvm/uvm_unix.c +++ b/sys/uvm/uvm_unix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_unix.c,v 1.65 2019/03/01 01:46:18 cheloha Exp $ */ +/* $OpenBSD: uvm_unix.c,v 1.66 2019/06/21 09:39:49 visa Exp $ */ /* $NetBSD: uvm_unix.c,v 1.18 2000/09/13 15:00:25 thorpej Exp $ */ /* @@ -72,7 +72,7 @@ sys_obreak(struct proc *p, void *v, register_t *retval) base = (vaddr_t)vm->vm_daddr; new = round_page((vaddr_t)SCARG(uap, nsize)); - if (new < base || (new - base) > p->p_rlimit[RLIMIT_DATA].rlim_cur) + if (new < base || (new - base) > lim_cur(RLIMIT_DATA)) return (ENOMEM); old = round_page(base + ptoa(vm->vm_dsize)); @@ -128,7 +128,7 @@ uvm_grow(struct proc *p, vaddr_t sp) #else si = atop((vaddr_t)vm->vm_minsaddr - sp) - vm->vm_ssize; #endif - if (vm->vm_ssize + si <= atop(p->p_rlimit[RLIMIT_STACK].rlim_cur)) + if (vm->vm_ssize + si <= atop(lim_cur(RLIMIT_STACK))) vm->vm_ssize += si; } |
