[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.1.10.0805071757520.3024@woody.linux-foundation.org>
Date: Wed, 7 May 2008 18:02:49 -0700 (PDT)
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Andrea Arcangeli <andrea@...ranet.com>
cc: Andrew Morton <akpm@...ux-foundation.org>, clameter@....com,
steiner@....com, holt@....com, npiggin@...e.de,
a.p.zijlstra@...llo.nl, kvm-devel@...ts.sourceforge.net,
kanojsarcar@...oo.com, rdreier@...co.com,
swise@...ngridcomputing.com, linux-kernel@...r.kernel.org,
avi@...ranet.com, linux-mm@...ck.org,
general@...ts.openfabrics.org, hugh@...itas.com,
rusty@...tcorp.com.au, aliguori@...ibm.com, chrisw@...hat.com,
marcelo@...ck.org, dada1@...mosbay.com, paulmck@...ibm.com
Subject: Re: [PATCH 08 of 11] anon-vma-rwsem
On Thu, 8 May 2008, Andrea Arcangeli wrote:
> Hi Andrew,
>
> On Wed, May 07, 2008 at 03:59:14PM -0700, Andrew Morton wrote:
> > CPU0: CPU1:
> >
> > spin_lock(global_lock)
> > spin_lock(a->lock); spin_lock(b->lock);
> ================== mmu_notifier_register()
If mmy_notifier_register() takes the global lock, it cannot happen here.
It will be blocked (by CPU0), so there's no way it can then cause an ABBA
deadlock. It will be released when CPU0 has taken *all* the locks it
needed to take.
> What we can do is to replace the mm_lock with a
> spin_lock(&global_lock) only if all places that takes i_mmap_lock
NO!
You replace mm_lock() with the sequence that Andrew gave you (and I
described):
spin_lock(&global_lock)
.. get all locks UNORDERED ..
spin_unlock(&global_lock)
and you're now done. You have your "mm_lock()" (which still needs to be
renamed - it should be a "mmu_notifier_lock()" or something like that),
but you don't need the insane sorting. At most you apparently need a way
to recognize duplicates (so that you don't deadlock on yourself), which
looks like a simple bit-per-vma.
The global lock doesn't protect any data structures itself - it just
protects two of these mm_lock() functions from ABBA'ing on each other!
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists