Skip to contentSkip to conversation

Question on i_mmap_mutex locking rule

DISCUSSION Aneesh Kumar K.V 2 participants 2 messages Apr 2, 2012 – Apr 10, 2012 Memory management

lore
Share & tools
lore
#0 lore raw

Hi,

I started looking at unmap_hugepage_range. unmap_hugepage_range takes i_mmap_mutex. But then the same lock is also taken higher up in the stack. ie via the below chain

unmap_mapping_range (i_mmap_mutex)
-> unmap_mapping_range_tree

    -> unmap_mapping_range_vma
       -> zap_page_range_single
          -> unmap_single_vma
             -> unmap_hugepage_range (i_mmap_mutex)

But there are other code path that doesn't take i_mmap_mutex. For ex:
-> madvise_dontneed
-> zap_page_range

      -> unmap_vmas
         -> unmap_single_vma
            -> unmap_page_range

similarly unmap_region also don't take i_mmap_mutex. Don't we need to ensure that we take i_mmap_mutex when we unmap a file backed range ?

-aneesh

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 7 lines · Aneesh Kumar K.V

Hi,

I started looking at unmap_hugepage_range. unmap_hugepage_range takes i_mmap_mutex. But then the same lock is also taken higher up in the stack. ie via the below chain

Quoted 7 lines

unmap_mapping_range (i_mmap_mutex)
-> unmap_mapping_range_tree

    -> unmap_mapping_range_vma
       -> zap_page_range_single
          -> unmap_single_vma
             -> unmap_hugepage_range (i_mmap_mutex)

why not deadlock ?

Quoted 8 lines

But there are other code path that doesn't take i_mmap_mutex. For ex:
-> madvise_dontneed
-> zap_page_range

      -> unmap_vmas
         -> unmap_single_vma
            -> unmap_page_range

IIUC, DONTNEED will not change vma layout...so it doesn't require i_mmap_mutex.

Thanks,
-Kame

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>