svn commit: r209761 - head/sys/kern

Attilio Rao attilio at FreeBSD.org
Wed Jul 7 12:00:13 UTC 2010


Author: attilio
Date: Wed Jul  7 12:00:11 2010
New Revision: 209761
URL: http://svn.freebsd.org/changeset/base/209761

Log:
  - 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

Modified:
  head/sys/kern/kern_clock.c

Modified: head/sys/kern/kern_clock.c
==============================================================================
--- head/sys/kern/kern_clock.c	Wed Jul  7 11:19:06 2010	(r209760)
+++ head/sys/kern/kern_clock.c	Wed Jul  7 12:00:11 2010	(r209761)
@@ -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


More information about the svn-src-all mailing list