lkml.org 
[lkml]   [2008]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.


\
 
 \ /
  Last update: 2008-05-08 01:43    [W:0.149 / U:1.216 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site