diff options
author | attilio <attilio@FreeBSD.org> | 2010-07-07 12:00:11 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2010-07-07 12:00:11 +0000 |
commit | 865de58a04e5e71901e212ee10f51b3eaf0de68d (patch) | |
tree | 0986e0f2c98b1b83320a5e2fd2f09a2236e9ad6c /sys/kern/kern_clock.c | |
parent | 11ebe7c039dba8300e25b31bef6b05e09b75ac1e (diff) | |
download | FreeBSD-src-865de58a04e5e71901e212ee10f51b3eaf0de68d.zip FreeBSD-src-865de58a04e5e71901e212ee10f51b3eaf0de68d.tar.gz |
- Simplify logic in handling ticks wrap-up
- Fix a bug where thread may be in sleeping state but the wchan won't
be set, leading to an empty container for sleepq_type(). [0]
Sponsored by: Sandvine Incorporated
[0] Submitted by: Bryan Venteicher
<bryanv at daemoninthecloset dot org>
MFC after: 3 days
X-MFC: 209577
Diffstat (limited to 'sys/kern/kern_clock.c')
-rw-r--r-- | sys/kern/kern_clock.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 5097862..c283b6b 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -202,8 +202,14 @@ deadlkres(void) FOREACH_PROC_IN_SYSTEM(p) { PROC_LOCK(p); FOREACH_THREAD_IN_PROC(p, td) { + + /* + * Once a thread is found in "interesting" + * state a possible ticks wrap-up needs to be + * checked. + */ thread_lock(td); - if (TD_ON_LOCK(td)) { + if (TD_ON_LOCK(td) && ticks < td->td_blktick) { /* * The thread should be blocked on a @@ -212,11 +218,6 @@ deadlkres(void) */ MPASS(td->td_blocked != NULL); - /* Handle ticks wrap-up. */ - if (ticks < td->td_blktick) { - thread_unlock(td); - continue; - } tticks = ticks - td->td_blktick; thread_unlock(td); if (tticks > blkticks) { @@ -232,13 +233,9 @@ deadlkres(void) panic("%s: possible deadlock detected for %p, blocked for %d ticks\n", __func__, td, tticks); } - } else if (TD_IS_SLEEPING(td)) { - - /* Handle ticks wrap-up. */ - if (ticks < td->td_blktick) { - thread_unlock(td); - continue; - } + } else if (TD_IS_SLEEPING(td) && + TD_ON_SLEEPQ(td) && + ticks < td->td_blktick) { /* * Check if the thread is sleeping on a |