Date: Thu, 20 Nov 2008 04:04:22 +0000 (UTC) From: Lawrence Stewart <lstewart@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r185116 - user/lstewart/misc_7.x/sys/kern Message-ID: <200811200404.mAK44M1n038537@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811200404.mAK44M1n038537>