svn commit: r192604 - in user/kmacy/releng_7_2_fcs/sys: dev/hwpmc sys

M. Warner Losh imp at bsdimp.com
Wed May 27 00:24:54 UTC 2009


In message: <3c1674c90905261118y282d9b0fn7d54630f507d8363 at mail.gmail.com>
            Kip Macy <kmacy at freebsd.org> writes:
: On Tue, May 26, 2009 at 5:30 AM, John Baldwin <jhb at freebsd.org> 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:
: >>   - remove pmc_kthread_mtx
: >>   - 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.  Usually 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 module
: > resulting in a fatal page fault in the kernel.
: 
: 
: Yes, that is why the kthread explicitly calls cv_signal after clearing
: 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


More information about the svn-src-user mailing list