[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0805071637360.14337@schroedinger.engr.sgi.com>
Date: Wed, 7 May 2008 16:39:39 -0700 (PDT)
From: Christoph Lameter <clameter@....com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
cc: Andrew Morton <akpm@...ux-foundation.org>,
Andrea Arcangeli <andrea@...ranet.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 Wed, 7 May 2008, Linus Torvalds wrote:
> The code that can take many locks, will have to get the global lock *and*
> order the types, but that's still trivial. It's something like
>
> spin_lock(&global_lock);
> for (vma = mm->mmap; vma; vma = vma->vm_next) {
> if (vma->anon_vma)
> spin_lock(&vma->anon_vma->lock);
> }
> for (vma = mm->mmap; vma; vma = vma->vm_next) {
> if (!vma->anon_vma && vma->vm_file && vma->vm_file->f_mapping)
> spin_lock(&vma->vm_file->f_mapping->i_mmap_lock);
> }
> spin_unlock(&global_lock);
Multiple vmas may share the same mapping or refer to the same anonymous
vma. The above code will deadlock since we may take some locks multiple
times.
--
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