From: claudio Date: Thu, 3 Oct 2024 10:20:05 +0000 (+0000) Subject: In rucheck() sum up the tusage from all threads to get the real current X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=79e5ab1ff58731a1cc508aac9e30affe8c359b78;p=openbsd 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@ --- 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);