diff options
| author | 2019-06-21 09:39:48 +0000 | |
|---|---|---|
| committer | 2019-06-21 09:39:48 +0000 | |
| commit | edc99bcd885f4004d6cffdbe82f15aa2eb27ee9c (patch) | |
| tree | 90a5c776fe52a9672304a33b0ce308c3c1f7763f /sys/kern/kern_exit.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 'sys/kern/kern_exit.c')
| -rw-r--r-- | sys/kern/kern_exit.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 74ac47d02f8..ab2f0de086d 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.177 2019/06/13 21:19:28 mpi Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.178 2019/06/21 09:39:48 visa Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -328,6 +328,15 @@ exit1(struct proc *p, int rv, int flags) KASSERT(pr->ps_refcnt > 0); } + /* Release the thread's read reference of resource limit structure. */ + if (p->p_limit != NULL) { + struct plimit *limit; + + limit = p->p_limit; + p->p_limit = NULL; + lim_free(limit); + } + /* * Other substructures are freed from reaper and wait(). */ @@ -636,7 +645,7 @@ process_zap(struct process *pr) free(pr->ps_ptstat, M_SUBPROC, sizeof(*pr->ps_ptstat)); pool_put(&rusage_pool, pr->ps_ru); KASSERT(TAILQ_EMPTY(&pr->ps_threads)); - limfree(pr->ps_limit); + lim_free(pr->ps_limit); crfree(pr->ps_ucred); pool_put(&process_pool, pr); nprocesses--; |
