From edc99bcd885f4004d6cffdbe82f15aa2eb27ee9c Mon Sep 17 00:00:00 2001 From: visa Date: Fri, 21 Jun 2019 09:39:48 +0000 Subject: 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@ --- sys/uvm/uvm_unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sys/uvm/uvm_unix.c') 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; } -- cgit v1.2.3-59-g8ed1b