From f5d5cb3c7c7fd0bee68bf429b82a51ec407eac71 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 17 Apr 2003 22:33:04 +0000 Subject: [PATCH] Tweak locking in the PS_XCPU handler to hold the sched_lock while reading p_runtime. --- sys/kern/subr_trap.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index 9cc7dbeec0a..74d8fd6650f 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -222,14 +222,15 @@ ast(struct trapframe *framep) if (sflag & PS_XCPU) { PROC_LOCK(p); rlim = &p->p_rlimit[RLIMIT_CPU]; - if (p->p_runtime.sec >= rlim->rlim_max) + mtx_lock_spin(&sched_lock); + if (p->p_runtime.sec >= rlim->rlim_max) { + mtx_unlock_spin(&sched_lock); killproc(p, "exceeded maximum CPU limit"); - else { - psignal(p, SIGXCPU); - mtx_lock_spin(&sched_lock); + } else { if (p->p_cpulimit < rlim->rlim_max) p->p_cpulimit += 5; mtx_unlock_spin(&sched_lock); + psignal(p, SIGXCPU); } PROC_UNLOCK(p); }