From: claudio Date: Wed, 22 May 2024 09:20:22 +0000 (+0000) Subject: Just grab the SCHED_LOCK() once in donice() before walking the ps_threads X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=f5a6fea6afbf41ba68c0a53f5a4f2277e47251f3;p=openbsd Just grab the SCHED_LOCK() once in donice() before walking the ps_threads list. setpriority() is trivial and probably faster than releasing and relocking SCHED_LOCK(). OK jca@ --- diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 04247e33094..6bc28d5aabc 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.82 2024/05/20 10:32:20 claudio Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.83 2024/05/22 09:20:22 claudio Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -213,11 +213,11 @@ donice(struct proc *curp, struct process *chgpr, int n) return (EACCES); chgpr->ps_nice = n; mtx_enter(&chgpr->ps_mtx); + SCHED_LOCK(s); TAILQ_FOREACH(p, &chgpr->ps_threads, p_thr_link) { - SCHED_LOCK(s); setpriority(p, p->p_estcpu, n); - SCHED_UNLOCK(s); } + SCHED_UNLOCK(s); mtx_leave(&chgpr->ps_mtx); return (0); }