svn commit: r185116 - user/lstewart/misc_7.x/sys/kern
Lawrence Stewart
lstewart at FreeBSD.org
Wed Nov 19 20:04:22 PST 2008
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));
More information about the svn-src-user
mailing list