From owner-svn-src-all@FreeBSD.ORG Sat Oct 23 13:16:40 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 41A14106566B; Sat, 23 Oct 2010 13:16:40 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 167918FC1E; Sat, 23 Oct 2010 13:16:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9NDGd9C087834; Sat, 23 Oct 2010 13:16:39 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9NDGd1B087831; Sat, 23 Oct 2010 13:16:39 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201010231316.o9NDGd1B087831@svn.freebsd.org> From: David Xu Date: Sat, 23 Oct 2010 13:16:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214238 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Oct 2010 13:16:40 -0000 Author: davidxu Date: Sat Oct 23 13:16:39 2010 New Revision: 214238 URL: http://svn.freebsd.org/changeset/base/214238 Log: In thr_exit() and kthread_exit(), only remove thread from hash if it can directly exit, otherwise let exit1() do it. The change should be in r213950, but for unknown reason, it was lost. Modified: head/sys/kern/kern_kthread.c head/sys/kern/kern_thr.c Modified: head/sys/kern/kern_kthread.c ============================================================================== --- head/sys/kern/kern_kthread.c Sat Oct 23 12:27:39 2010 (r214237) +++ head/sys/kern/kern_kthread.c Sat Oct 23 13:16:39 2010 (r214238) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -315,17 +316,20 @@ kthread_exit(void) p = curthread->td_proc; - tidhash_remove(curthread); /* A module may be waiting for us to exit. */ wakeup(curthread); + rw_wlock(&tidhash_lock); PROC_LOCK(p); if (p->p_numthreads == 1) { PROC_UNLOCK(p); + rw_wunlock(&tidhash_lock); kproc_exit(0); /* NOTREACHED. */ } + LIST_REMOVE(curthread, td_hash); + rw_wunlock(&tidhash_lock); PROC_SLOCK(p); thread_exit(); } Modified: head/sys/kern/kern_thr.c ============================================================================== --- head/sys/kern/kern_thr.c Sat Oct 23 12:27:39 2010 (r214237) +++ head/sys/kern/kern_thr.c Sat Oct 23 13:16:39 2010 (r214238) @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -284,23 +285,23 @@ thr_exit(struct thread *td, struct thr_e kern_umtx_wake(td, uap->state, INT_MAX, 0); } - tidhash_remove(td); - + rw_wlock(&tidhash_lock); PROC_LOCK(p); - tdsigcleanup(td); - PROC_SLOCK(p); - /* * Shutting down last thread in the proc. This will actually * call exit() in the trampoline when it returns. */ if (p->p_numthreads != 1) { + LIST_REMOVE(td, td_hash); + rw_wunlock(&tidhash_lock); + tdsigcleanup(td); + PROC_SLOCK(p); thread_stopped(p); thread_exit(); /* NOTREACHED */ } - PROC_SUNLOCK(p); PROC_UNLOCK(p); + rw_wunlock(&tidhash_lock); return (0); }