diff options
author | 2019-06-10 03:15:53 +0000 | |
---|---|---|
committer | 2019-06-10 03:15:53 +0000 | |
commit | 3cb3b60b5ff33f40f1ca18594bc0f47646bba98b (patch) | |
tree | 361e0ae7fa8a9d979abdff04a355cbb70dd9f31c /sys/kern/kern_resource.c | |
parent | move solve_dependency up, so that pkg_create is happy again (diff) | |
download | wireguard-openbsd-3cb3b60b5ff33f40f1ca18594bc0f47646bba98b.tar.xz wireguard-openbsd-3cb3b60b5ff33f40f1ca18594bc0f47646bba98b.zip |
Avoid changing resource limits in rucheck() by introducing a new state
variable that tracks when to send next SIGXCPU. This eases MP work and
prevents accidental alteration of shared resource limit structs.
OK mpi@ semarie@
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r-- | sys/kern/kern_resource.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 24559ecda99..3bc9425020a 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.63 2019/06/02 03:58:28 visa Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.64 2019/06/10 03:15:53 visa Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -53,6 +53,9 @@ #include <uvm/uvm_extern.h> +/* SIGXCPU interval in seconds of process runtime */ +#define SIGXCPU_INTERVAL 5 + void tuagg_sub(struct tusage *, struct proc *); /* @@ -506,7 +509,7 @@ rucheck(void *arg) { struct process *pr = arg; struct rlimit *rlim; - rlim_t runtime; + time_t runtime; int s; KERNEL_ASSERT_LOCKED(); @@ -516,14 +519,12 @@ rucheck(void *arg) SCHED_UNLOCK(s); rlim = &pr->ps_limit->pl_rlimit[RLIMIT_CPU]; - if (runtime >= rlim->rlim_cur) { - if (runtime >= rlim->rlim_max) { + if ((rlim_t)runtime >= rlim->rlim_cur) { + if ((rlim_t)runtime >= rlim->rlim_max) { prsignal(pr, SIGKILL); - } else { + } else if (runtime >= pr->ps_nextxcpu) { prsignal(pr, SIGXCPU); - if (rlim->rlim_cur < rlim->rlim_max) - rlim->rlim_cur = MIN(rlim->rlim_cur + 5, - rlim->rlim_max); + pr->ps_nextxcpu = runtime + SIGXCPU_INTERVAL; } } |