diff options
author | John Baldwin <jhb@FreeBSD.org> | 2003-04-17 22:16:58 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2003-04-17 22:16:58 +0000 |
commit | f36403612a9783732ee393d2407b5c0bea30f86d (patch) | |
tree | 6ada4ec82b4fb9e578e61b826028f93601a0db83 /sys/fs/procfs | |
parent | ab0eee55638f4ed525b6a81b05f44e039d01c548 (diff) | |
download | src-f36403612a9783732ee393d2407b5c0bea30f86d.tar.gz src-f36403612a9783732ee393d2407b5c0bea30f86d.zip |
- Use a local variable to close a minor race when determining if the wmesg
printed out needs a prefix such as when a thread is blocked on a lock.
- Use another local variable to close another race for the td_wmesg and
td_wchan members of struct thread.
Notes
Notes:
svn path=/head/; revision=113620
Diffstat (limited to 'sys/fs/procfs')
-rw-r--r-- | sys/fs/procfs/procfs_status.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index f4110676c4be..d9aeecfce815 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -70,6 +70,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) struct thread *tdfirst; struct tty *tp; struct ucred *cr; + const char *wmesg; char *pc; char *sep; int pid, ppid, pgid, sid; @@ -95,7 +96,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) sbuf_putc(sb, *pc); } while (*++pc); sbuf_printf(sb, " %d %d %d %d ", pid, ppid, pgid, sid); - if ((p->p_flag&P_CONTROLT) && (tp = sess->s_ttyp)) + if ((p->p_flag & P_CONTROLT) && (tp = sess->s_ttyp)) sbuf_printf(sb, "%d,%d ", major(tp->t_dev), minor(tp->t_dev)); else sbuf_printf(sb, "%d,%d ", -1, -1); @@ -115,6 +116,18 @@ procfs_doprocstatus(PFS_FILL_ARGS) } mtx_lock_spin(&sched_lock); + if (p->p_flag & P_THREADED) + wmesg = "-kse- "; + else { + tdfirst = FIRST_THREAD_IN_PROC(p); + if (tdfirst->td_wchan != NULL) { + KASSERT(tdfirst->td_wmesg != NULL, + ("wchan %p has no wmesg", tdfirst->td_wchan)); + wmesg = tdfirst->td_wmesg; + } else + wmesg = "nochan"; + } + if (p->p_sflag & PS_INMEM) { struct timeval ut, st; @@ -130,14 +143,7 @@ procfs_doprocstatus(PFS_FILL_ARGS) sbuf_printf(sb, " -1,-1 -1,-1 -1,-1"); } - if (p->p_flag & P_THREADED) - sbuf_printf(sb, " %s", "-kse- "); - else { - tdfirst = FIRST_THREAD_IN_PROC(p); /* XXX diff from td? */ - sbuf_printf(sb, " %s", - (tdfirst->td_wchan && tdfirst->td_wmesg) ? - tdfirst->td_wmesg : "nochan"); - } + sbuf_printf(sb, " %s", wmesg); cr = p->p_ucred; |