Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jul 2010 10:11:10 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r209931 - stable/8/sys/kern
Message-ID:  <201007121011.o6CABAng065234@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: attilio
Date: Mon Jul 12 10:11:10 2010
New Revision: 209931
URL: http://svn.freebsd.org/changeset/base/209931

Log:
  MFC r209577, r209761:
  - Fix a lock leak in case the ticks wrapped up
  - Simplify the logic for handling ticks wrap-ups
  - Fix a bug where a thread may be in sleepign state but not on a
    sleepqueue chain still.
  
  Sponsored by:	Sandvine Incorporated

Modified:
  stable/8/sys/kern/kern_clock.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)

Modified: stable/8/sys/kern/kern_clock.c
==============================================================================
--- stable/8/sys/kern/kern_clock.c	Mon Jul 12 09:38:44 2010	(r209930)
+++ stable/8/sys/kern/kern_clock.c	Mon Jul 12 10:11:10 2010	(r209931)
@@ -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,9 +218,6 @@ deadlkres(void)
 					 */
 					MPASS(td->td_blocked != NULL);
 
-					/* Handle ticks wrap-up. */
-					if (ticks < td->td_blktick)
-						continue;
 					tticks = ticks - td->td_blktick;
 					thread_unlock(td);
 					if (tticks > blkticks) {
@@ -230,11 +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)
-						continue;
+				} else if (TD_IS_SLEEPING(td) &&
+				    TD_ON_SLEEPQ(td) &&
+				    ticks < td->td_blktick) {
 
 					/*
 					 * Check if the thread is sleeping on a



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201007121011.o6CABAng065234>