diff options
Diffstat (limited to 'sys/kern/kern_racct.c')
| -rw-r--r-- | sys/kern/kern_racct.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c index 2aab151aba08..d1324935bdc3 100644 --- a/sys/kern/kern_racct.c +++ b/sys/kern/kern_racct.c @@ -949,8 +949,10 @@ racct_proc_exit(struct proc *p) } /* - * Called after credentials change, to move resource utilisation - * between raccts. + * Called to signal credentials change, to move resource utilisation + * between raccts. Must be called with the proc lock held, in the same span as + * the credentials change itself (i.e., without the proc lock being unlocked + * between the two), but the order does not matter. */ void racct_proc_ucred_changed(struct proc *p, struct ucred *oldcred, @@ -1236,16 +1238,20 @@ racct_updatepcpu_containers(void) racct_updatepcpu_post, NULL, NULL); } +static bool +racct_proc_to_skip(const struct proc *p) +{ + PROC_LOCK_ASSERT(p, MA_OWNED); + return (p->p_state != PRS_NORMAL || (p->p_flag & P_IDLEPROC) != 0); +} + static void racctd(void) { struct proc *p; - struct proc *idle; ASSERT_RACCT_ENABLED(); - idle = STAILQ_FIRST(&cpuhead)->pc_idlethread->td_proc; - for (;;) { racct_decay(); @@ -1253,12 +1259,7 @@ racctd(void) FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - if (p == idle) { - PROC_UNLOCK(p); - continue; - } - if (p->p_state != PRS_NORMAL || - (p->p_flag & P_IDLEPROC) != 0) { + if (racct_proc_to_skip(p)) { PROC_UNLOCK(p); continue; } @@ -1284,7 +1285,7 @@ racctd(void) */ FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); - if (p->p_state != PRS_NORMAL) { + if (racct_proc_to_skip(p)) { PROC_UNLOCK(p); continue; } |
