diff options
author | trasz <trasz@FreeBSD.org> | 2011-07-06 20:06:44 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2011-07-06 20:06:44 +0000 |
commit | 4a17b24427e55ec7e1862b08a0a9247f0717d010 (patch) | |
tree | 443d8da9aef22fdf042ab6f2cf16f5e2d4f04bd3 /sys/kern/kern_exit.c | |
parent | 1adac93bc0e2f40ac5d98734f9451cb1a0f42124 (diff) | |
download | FreeBSD-src-4a17b24427e55ec7e1862b08a0a9247f0717d010.zip FreeBSD-src-4a17b24427e55ec7e1862b08a0a9247f0717d010.tar.gz |
All the racct_*() calls need to happen with the proc locked. Fixing this
won't happen before 9.0. This commit adds "#ifdef RACCT" around all the
"PROC_LOCK(p); racct_whatever(p, ...); PROC_UNLOCK(p)" instances, in order
to avoid useless locking/unlocking in kernels built without "options RACCT".
Diffstat (limited to 'sys/kern/kern_exit.c')
-rw-r--r-- | sys/kern/kern_exit.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index bb25d17..30b94b6 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -744,9 +744,11 @@ proc_reap(struct thread *td, struct proc *p, int *status, int options, * Destroy resource accounting information associated with the process. */ racct_proc_exit(p); +#ifdef RACCT PROC_LOCK(p->p_pptr); racct_sub(p->p_pptr, RACCT_NPROC, 1); PROC_UNLOCK(p->p_pptr); +#endif /* * Free credentials, arguments, and sigacts. @@ -905,19 +907,23 @@ loop: void proc_reparent(struct proc *child, struct proc *parent) { +#ifdef RACCT int locked; +#endif sx_assert(&proctree_lock, SX_XLOCKED); PROC_LOCK_ASSERT(child, MA_OWNED); if (child->p_pptr == parent) return; +#ifdef RACCT locked = PROC_LOCKED(parent); if (!locked) PROC_LOCK(parent); racct_add_force(parent, RACCT_NPROC, 1); if (!locked) PROC_UNLOCK(parent); +#endif PROC_LOCK(child->p_pptr); racct_sub(child->p_pptr, RACCT_NPROC, 1); sigqueue_take(child->p_ksi); |