cvs commit: src/sys/i386/i386 vm_machdep.c

Peter Wemm peter at wemm.org
Sun Mar 7 17:31:18 PST 2004


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 at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5


More information about the cvs-src mailing list