From: Hugh Dickins <hugh@veritas.com>
To: "Chen, Kenneth W" <kenneth.w.chen@intel.com>
Cc: linux-mm@kvack.org
Subject: Re: Question: why hold source mm->mmap_sem write sem in dup_mmap()?
Date: Sat, 30 Sep 2006 15:45:12 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0609301504030.5193@blonde.wat.veritas.com> (raw)
In-Reply-To: <000301c6e42c$12a62490$ff0da8c0@amr.corp.intel.com>
On Fri, 29 Sep 2006, Chen, Kenneth W wrote:
> 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?
Good question, I think you're right: it's just a leftover from when 2.4.3
changed mmap_sem to an rwsem, and most down()s became down_write()s, with
the advantageously-concurrent faulting ones changed to down_read()s.
(For a while it was thought to hold rss steady, so copy_page_range didn't
bother to increment: but that only applied to faulting in, it was no
protection against vmscan swapping out, and so had to be fixed later.)
Hold on, there is one thing it's guarding against: expand_stack(), which
may extend stack vma with only down_read of mmap_sem (+ anon_vma_lock),
and in the downward case needs to adjust vm_start and vm_pgoff together.
Though I doubt that's conscious, nor a good reason to keep the down_write.
And I notice that total_vm and the vm_stat_account fields have been
copied over from oldmm to new mm, without any hold on mmap_sem at all:
not very serious, but we ought to fix it.
Hugh
--
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>
prev parent reply other threads:[~2006-09-30 14:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-30 1:02 Chen, Kenneth W
2006-09-30 14:45 ` Hugh Dickins [this message]
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=Pine.LNX.4.64.0609301504030.5193@blonde.wat.veritas.com \
--to=hugh@veritas.com \
--cc=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