Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Mar 2004 17:31:14 -0800
From:      Peter Wemm <peter@wemm.org>
To:        Alan Cox <alc@cs.rice.edu>
Cc:        Peter Wemm <peter@FreeBSD.org>
Subject:   Re: cvs commit: src/sys/i386/i386 vm_machdep.c
Message-ID:  <200403071731.14880.peter@wemm.org>
In-Reply-To: <20040308005242.GG21071@cs.rice.edu>
References:  <200403080027.i280RXIC041557@repoman.freebsd.org> <20040308005242.GG21071@cs.rice.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday 07 March 2004 04:52 pm, Alan Cox wrote:
> On Sun, Mar 07, 2004 at 04:27:33PM -0800, Peter Wemm wrote:
> > peter       2004/03/07 16:27:33 PST
> >
> >   FreeBSD src repository
> >
> >   Modified files:
> >     sys/i386/i386        vm_machdep.c
> >   Log:
> >   Other parts of the tree do not protect calls to kmem_free() with
> > Giant, so remove it from here.  The most notable examples include
> > vm_mmap(). This removes one more Giant event from exit(2).
> >
> >   Revision  Changes    Path
> >   1.226     +0 -2      src/sys/i386/i386/vm_machdep.c
>
> Whether this is safe depends on whether the underlying pages need to
> be unwired.  An explanation can be found in uma_large_free().
> Unwiring dips into the pmap, acquiring Giant before doing so.  The
> consequences would be a LOR, but not a race.

Speakling of which, Kris pasted a LOR involving this very code..

<BugMagnet>  1st 0xc07d9d40 UMA lock (UMA lock) @ vm/uma_core.c:1213
<BugMagnet>  2nd 0xc07a0540 Giant (Giant) @ vm/uma_core.c:2061

void
uma_large_free(uma_slab_t slab)
{
        vsetobj((vm_offset_t)slab->us_data, kmem_object);
        /*
         * XXX: We get a lock order reversal if we don't have Giant:
         * vm_map_remove (locks system map) -> vm_map_delete ->
         *    vm_map_entry_unwire -> vm_fault_unwire -> mtx_lock(&Giant)
         */
        if (!mtx_owned(&Giant)) {
2061>>  mtx_lock(&Giant);
                page_free(slab->us_data, slab->us_size, slab->us_flags);
                mtx_unlock(&Giant);
        } else
                page_free(slab->us_data, slab->us_size, slab->us_flags);
        uma_zfree_internal(slabzone, slab, NULL, 0);
}
I'm guessing it came from a uma_reclaim()..

Meanwhile, would it be an idea to back out the Giant removal around the 
kmem_free() in vm_machdep.c?  Its a rarely executed code path.

I wish there was a way to keep notes about this in the source.  Trying 
to figure out the quirks of this stuff is painful.

-- 
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403071731.14880.peter>