diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-10-03 10:20:06 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2024-10-03 10:20:06 +0000 |
commit | 0c5252fd282e8bea40f6801180deeaa515569707 (patch) | |
tree | 02c94e230bcdc16dc905136083b8b31531a72726 /sys | |
parent | 7f76e5eed584e3d0a8d3c4b1a5869b9ad4c8431c (diff) |
In rucheck() sum up the tusage from all threads to get the real current
runtime of the process. Also this no longer needs the SCHED_LOCK().
OK mpi@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_resource.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 403f4ad41a2..8796b4833d3 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.89 2024/10/01 09:22:25 claudio Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.90 2024/10/03 10:20:05 claudio Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -578,19 +578,22 @@ void rucheck(void *arg) { struct rlimit rlim; + struct tusage tu = { 0 }; struct process *pr = arg; + struct proc *q; time_t runtime; KERNEL_ASSERT_LOCKED(); - SCHED_LOCK(); - runtime = pr->ps_tu.tu_runtime.tv_sec; - SCHED_UNLOCK(); - mtx_enter(&pr->ps_mtx); rlim = pr->ps_limit->pl_rlimit[RLIMIT_CPU]; + tuagg_sumup(&tu, &pr->ps_tu); + TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) + tuagg_sumup(&tu, &q->p_tu); mtx_leave(&pr->ps_mtx); + runtime = tu.tu_runtime.tv_sec; + if ((rlim_t)runtime >= rlim.rlim_cur) { if ((rlim_t)runtime >= rlim.rlim_max) { prsignal(pr, SIGKILL); |