Re: [PATCH] rmap: make anon_vma_prepare link in all the anon_vmasof a mergeable VMA
From: Rik van Riel
Date: Wed Apr 07 2010 - 10:49:58 EST
On 04/07/2010 03:00 AM, KOSAKI Motohiro wrote:
Hmm.. probably I'm moron.
Someone might be, but it's not you :)
I'm also confusing this locking rule as same as linus said.
after this patch, new locking order are
So, Why mmap_sem read lock can protect vma->anon_vma_chain?
An another threads seems to be able to change avc list concurrentlly and freely.
You are right, the code needs to take the pagetable_lock
around the call to anon_vma_clone, so other threads
get locked out.
This means the locking order has now been inverted,
with the pagetable_lock on the outside and the
anon_vma locks on the inside.
I have checked all the other call sites to the
anon_vma code. The direct callers of anon_vma_clone
and anon_vma_fork already hold the mmap_sem for
write. The callers of anon_vma_prepare hold the
mmap_sem for read - so excluding other callers of
anon_vma_prepare with the page_table_lock is enough.
mm_take_all_locks has the mmap_sem for write.
There seem to be no other traversals of the same_vma
list, so changing the locking order to have the
page_table_lock on the outside of the anon_vma locks
plus, Why don't we need "vma->anon_vma = merge_vma->anon_vma" assignment?
if vma->anon_vma keep NULL, I think anon_vma_prepare() call anon_vma_clone()
Added in the new version. See the next email.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/