diff options
author | jhb <jhb@FreeBSD.org> | 2011-03-24 18:40:11 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2011-03-24 18:40:11 +0000 |
commit | c7ac62aecd199084355eed0c34e006b1a886e37e (patch) | |
tree | b8f82913909a64d0acd11bf6bd0728bcb4cc6c84 /sys/compat/linprocfs | |
parent | 7a8bd43974c3b65965d0a1661898bf7a3f1ff052 (diff) | |
download | FreeBSD-src-c7ac62aecd199084355eed0c34e006b1a886e37e.zip FreeBSD-src-c7ac62aecd199084355eed0c34e006b1a886e37e.tar.gz |
Fix some locking nits with the p_state field of struct proc:
- Hold the proc lock while changing the state from PRS_NEW to PRS_NORMAL
in fork to honor the locking requirements. While here, expand the scope
of the PROC_LOCK() on the new process (p2) to avoid some LORs. Previously
the code was locking the new child process (p2) after it had locked the
parent process (p1). However, when locking two processes, the safe order
is to lock the child first, then the parent.
- Fix various places that were checking p_state against PRS_NEW without
having the process locked to use PROC_LOCK(). Every place was already
locking the process, just after the PRS_NEW check.
- Remove or reduce the use of PROC_SLOCK() for places that were checking
p_state against PRS_NEW. The PROC_LOCK() alone is sufficient for reading
the current state.
- Reorder fill_kinfo_proc() slightly so it only acquires PROC_SLOCK() once.
MFC after: 1 week
Diffstat (limited to 'sys/compat/linprocfs')
-rw-r--r-- | sys/compat/linprocfs/linprocfs.c | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 3ff9443..b3d4e9c 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -740,7 +740,6 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) if (P_SHOULDSTOP(p)) { state = "T (stopped)"; } else { - PROC_SLOCK(p); switch(p->p_state) { case PRS_NEW: state = "I (idle)"; @@ -770,7 +769,6 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) state = "? (unknown)"; break; } - PROC_SUNLOCK(p); } fill_kinfo_proc(p, &kp); |