linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
To: linux-mm@kvack.org
Subject: Question: why hold source mm->mmap_sem write sem in dup_mmap()?
Date: Fri, 29 Sep 2006 18:02:16 -0700	[thread overview]
Message-ID: <000301c6e42c$12a62490$ff0da8c0@amr.corp.intel.com> (raw)

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>

             reply	other threads:[~2006-09-30  1:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-30  1:02 Chen, Kenneth W [this message]
2006-09-30 14:45 ` Hugh Dickins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='000301c6e42c$12a62490$ff0da8c0@amr.corp.intel.com' \
    --to=kenneth.w.chen@intel.com \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox