From owner-svn-src-user@FreeBSD.ORG Wed May 27 00:24:54 2009 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 327CC106566B; Wed, 27 May 2009 00:24:54 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id E3DA48FC20; Wed, 27 May 2009 00:24:53 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id n4R0MVcw088429; Tue, 26 May 2009 18:22:31 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 26 May 2009 18:22:51 -0600 (MDT) Message-Id: <20090526.182251.-409398290.imp@bsdimp.com> To: kmacy@FreeBSD.org From: "M. Warner Losh" In-Reply-To: <3c1674c90905261118y282d9b0fn7d54630f507d8363@mail.gmail.com> References: <200905222145.n4MLjhm3019802@svn.freebsd.org> <200905260830.36831.jhb@freebsd.org> <3c1674c90905261118y282d9b0fn7d54630f507d8363@mail.gmail.com> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Cc: src-committers@FreeBSD.org, jhb@FreeBSD.org, svn-src-user@FreeBSD.org Subject: Re: svn commit: r192604 - in user/kmacy/releng_7_2_fcs/sys: dev/hwpmc sys 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: Wed, 27 May 2009 00:24:54 -0000 In message: <3c1674c90905261118y282d9b0fn7d54630f507d8363@mail.gmail.co= m> Kip Macy writes: : On Tue, May 26, 2009 at 5:30 AM, John Baldwin wrote= : : > On Friday 22 May 2009 5:45:43 pm Kip Macy wrote: : >> Author: kmacy : >> Date: Fri May 22 21:45:43 2009 : >> New Revision: 192604 : >> URL: http://svn.freebsd.org/changeset/base/192604 : >> : >> Log: : >> =A0 - remove pmc_kthread_mtx : >> =A0 - replace sleep/wakeup on kthread with a condvar : > : > If you do not sleep on the kthread/kproc when waiting for a kthread= to : > exit, then you open up a race window. =A0Usually this matters more = for : > any kthreads that live in a module since the race allows the module= to : > be unmapped before the thread is finished executing code from the m= odule : > resulting in a fatal page fault in the kernel. : = : = : Yes, that is why the kthread explicitly calls cv_signal after clearin= g : the kthread pointer. The race here is that any kthread is still executing code after the module is unloaded. This fix doesn't solve that race, since the only way to solve it is to have the scheduler tell you when the thread is gone, which is what the sleep/wakup on the kthread does. Warner