From owner-svn-src-user@FreeBSD.ORG Thu Nov 20 04:04:22 2008 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C0BF11065674; Thu, 20 Nov 2008 04:04:22 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B2CD18FC16; Thu, 20 Nov 2008 04:04:22 +0000 (UTC) (envelope-from lstewart@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mAK44Mlk038538; Thu, 20 Nov 2008 04:04:22 GMT (envelope-from lstewart@svn.freebsd.org) Received: (from lstewart@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mAK44M1n038537; Thu, 20 Nov 2008 04:04:22 GMT (envelope-from lstewart@svn.freebsd.org) Message-Id: <200811200404.mAK44M1n038537@svn.freebsd.org> From: Lawrence Stewart Date: Thu, 20 Nov 2008 04:04:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r185116 - user/lstewart/misc_7.x/sys/kern X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Nov 2008 04:04:22 -0000 Author: lstewart Date: Thu Nov 20 04:04:22 2008 New Revision: 185116 URL: http://svn.freebsd.org/changeset/base/185116 Log: Fix a bug in kthread_exit() which led to potential deadlock in code that was relying on the documented behaviour in the kthread(9) man page. This brings the wakeup() related behaviour of kthread_exit in 7.x inline with 8.x. I've tested the fix with a simple scenario that was previously deadlocking. A waiting thread waits on a terminating thread by calling mtx_sleep() with the "chan" argument set to the *thread obtained by calling FIRST_THREAD_IN_PROC(*proc_that_will_exit). Without this patch, the waiting thread never gets woken because kthread_exit() calls wakeup() on the *proc. With this patch, the wait thread gets woken and all is good in the world again. For more details, refer to: http://lists.freebsd.org/pipermail/freebsd-arch/2008-November/008688.html Discussed with: attilio@, julian@ Modified: user/lstewart/misc_7.x/sys/kern/kern_kthread.c Modified: user/lstewart/misc_7.x/sys/kern/kern_kthread.c ============================================================================== --- user/lstewart/misc_7.x/sys/kern/kern_kthread.c Thu Nov 20 03:34:36 2008 (r185115) +++ user/lstewart/misc_7.x/sys/kern/kern_kthread.c Thu Nov 20 04:04:22 2008 (r185116) @@ -144,6 +144,7 @@ kthread_exit(int ecode) * Wakeup anyone waiting for us to exit. */ wakeup(p); + wakeup(td); /* Buh-bye! */ exit1(td, W_EXITCODE(ecode, 0));