linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Question: why hold source mm->mmap_sem write sem in dup_mmap()?
@ 2006-09-30  1:02 Chen, Kenneth W
  2006-09-30 14:45 ` Hugh Dickins
  0 siblings, 1 reply; 2+ messages in thread
From: Chen, Kenneth W @ 2006-09-30  1:02 UTC (permalink / raw)
  To: linux-mm

In the call chain of copy_page_range coming from do_fork(), dup_mmap holds
write semaphore on the oldmm.  I don't see copy_page_range() or dup_mmap
itself alter the source (oldmm)'s address space, what is the reason to hold
write semaphore on the source mm?  Won't a down_read(&oldmm->mmap_sem) be
sufficient?  Did I miss something there?


do_fork
  copy_process
    copy_mm
      dup_mm
        dup_mmap
          copy_page_range

static inline int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
{
        ...
        down_write(&oldmm->mmap_sem);
        flush_cache_mm(oldmm);
        down_write_nested(&mm->mmap_sem, SINGLE_DEPTH_NESTING);
        ...
        for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
                ...
                retval = copy_page_range(mm, oldmm, mpnt);
        }
        ...

        up_write(&mm->mmap_sem);
        flush_tlb_mm(oldmm);
        up_write(&oldmm->mmap_sem);
}

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-09-30 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-30  1:02 Question: why hold source mm->mmap_sem write sem in dup_mmap()? Chen, Kenneth W
2006-09-30 14:45 ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox